62 # @todo FIXME: Doesn't inherit right
63 return $t == null ? null :
new self(
$t );
64 # return $t == null ? null : new static( $t ); // PHP 5.3
72 $this->mPage->setFile( $file );
73 $this->displayImg = $file;
74 $this->fileLoaded =
true;
78 if ( $this->fileLoaded ) {
81 $this->fileLoaded =
true;
83 $this->displayImg = $img =
false;
84 Hooks::run(
'ImagePageFindFile', [ $this, &$img, &$this->displayImg ] );
91 $this->mPage->setFile( $img );
92 if ( !$this->displayImg ) {
93 $this->displayImg = $img;
95 $this->repo = $img->getRepo();
103 $this->
getContext()->getOutput()->setArticleBodyOnly(
true );
118 if ( $this->
getTitle()->getNamespace() !=
NS_FILE || ( $diff !== null && $diffOnly ) ) {
125 if ( $this->
getTitle()->getNamespace() ==
NS_FILE && $this->mPage->getFile()->getRedirected() ) {
126 if ( $this->
getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !== null ) {
129 $request->setVal(
'diffonly',
'true' );
135 $out->setPageTitle( $this->
getTitle()->getPrefixedText() );
146 if ( $wgShowEXIF && $this->displayImg->exists() ) {
148 $formattedMetadata = $this->displayImg->formatMetadata( $this->
getContext() );
149 $showmeta = $formattedMetadata !==
false;
154 if ( !$diff && $this->displayImg->exists() ) {
162 # No need to display noarticletext, we use our own message, output in openShowImage()
163 if ( $this->mPage->getId() ) {
164 # NS_FILE is in the user language, but this section (the actual wikitext)
165 # should be in page content language
166 $pageLang = $this->
getTitle()->getPageViewLanguage();
168 'lang' => $pageLang->getHtmlCode(),
'dir' => $pageLang->getDir(),
169 'class' =>
'mw-content-' . $pageLang->getDir() ] ) );
175 # Just need to set the right headers
176 $out->setArticleFlag(
true );
177 $out->setPageTitle( $this->
getTitle()->getPrefixedText() );
181 # Show shared description, if needed
182 if ( $this->mExtraDescription ) {
183 $fol = $this->
getContext()->msg(
'shareddescriptionfollows' );
184 if ( !$fol->isDisabled() ) {
185 $out->addWikiText( $fol->plain() );
187 $out->addHTML(
'<div id="shared-image-desc">' . $this->mExtraDescription .
"</div>\n" );
195 [
'id' =>
'filelinks' ],
198 # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
199 # Yet we return metadata about the target. Definitely an issue in the FileRepo
202 # Allow extensions to add something after the image links
212 [
'id' =>
'metadata' ],
215 $out->addModules( [
'mediawiki.action.view.metadata' ] );
219 if ( !$this->repo->isLocal() ) {
220 $css = $this->repo->getDescriptionStylesheetUrl();
226 $out->addModuleStyles(
'filepage' );
229 $out->addModuleStyles(
'mediawiki.action.view.filepage' );
248 '<li><a href="#file">' . $this->
getContext()->msg(
'file-anchor-link' )->escaped() .
'</a></li>',
249 '<li><a href="#filehistory">' . $this->
getContext()->msg(
'filehist' )->escaped() .
'</a></li>',
250 '<li><a href="#filelinks">' . $this->
getContext()->msg(
'imagelinks' )->escaped() .
'</a></li>',
253 Hooks::run(
'ImagePageShowTOC', [ $this, &$r ] );
256 $r[] =
'<li><a href="#metadata">' .
257 $this->
getContext()->msg(
'metadata' )->escaped() .
261 return '<ul id="filetoc">' . implode(
"\n", $r ) .
'</ul>';
273 $r =
"<div class=\"mw-imagepage-section-metadata\">";
274 $r .= $this->
getContext()->msg(
'metadata-help' )->plain();
275 $r .=
"<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
276 foreach ( $metadata
as $type => $stuff ) {
277 foreach ( $stuff
as $v ) {
278 # @todo FIXME: Why is this using escapeId for a class?!
280 if (
$type ==
'collapsed' ) {
282 $class .=
' collapsable';
284 $r .=
"<tr class=\"$class\">\n";
285 $r .=
"<th>{$v['name']}</th>\n";
286 $r .=
"<td>{$v['value']}</td>\n</tr>";
289 $r .=
"</table>\n</div>\n";
302 if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->
getId() ) {
305 return parent::getContentObject();
315 $dirmark =
$lang->getDirMarkEntity();
320 $maxHeight = $max[1];
322 if ( $this->displayImg->exists() ) {
325 if ( is_null(
$page ) ) {
332 $renderLang =
$request->getVal(
'lang' );
333 if ( !is_null( $renderLang ) ) {
334 $handler = $this->displayImg->getHandler();
342 $width_orig = $this->displayImg->getWidth(
$page );
343 $width = $width_orig;
344 $height_orig = $this->displayImg->getHeight(
$page );
345 $height = $height_orig;
348 $linktext = $filename;
350 Hooks::run(
'ImageOpenShowImageInlineBefore', [ &$this, &
$out ] );
352 if ( $this->displayImg->allowInlineDisplay() ) {
354 # "Download high res version" link below the image
355 # $msgsize = $this->getContext()->msg( 'file-info-size', $width_orig, $height_orig,
356 # Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
357 # We'll show a thumbnail of this image
358 if ( $width > $maxWidth || $height > $maxHeight || $this->displayImg->isVectorized() ) {
360 $maxWidth, $maxHeight, $width, $height
362 $linktext = $this->
getContext()->msg(
'show-big-image' )->escaped();
364 $thumbSizes = $this->
getThumbSizes( $width_orig, $height_orig );
365 # Generate thumbnails or thumbnail links as needed...
367 foreach ( $thumbSizes
as $size ) {
376 if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig )
377 || ( $this->displayImg->isVectorized()
380 && $size[0] != $width && $size[1] != $height
384 $otherSizes[] = $sizeLink;
388 $otherSizes = array_unique( $otherSizes );
392 if ( count( $otherSizes ) ) {
396 [
'class' =>
'mw-filepage-other-resolutions' ],
397 $this->
getContext()->msg(
'show-big-image-other' )
398 ->rawParams(
$lang->pipeList( $otherSizes ) )
399 ->params( count( $otherSizes ) )
403 } elseif ( $width == 0 && $height == 0 ) {
404 # Some sort of audio file that doesn't have dimensions
405 # Don't output a no hi res message for such a file
408 # Image is small enough to show full size on image page
409 $msgsmall = $this->
getContext()->msg(
'file-nohires' )->parse();
414 $thumbnail = $this->displayImg->transform(
$params );
419 [
'class' =>
'mw-filepage-resolutioninfo' ],
423 $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
425 $out->addModules(
'mediawiki.page.image.pagination' );
426 $out->addHTML(
'<table class="multipageimage"><tr><td>' );
431 'alt' => $this->displayImg->getTitle()->getPrefixedText(),
434 $out->addHTML(
'<div class="fullImageLink" id="file">' .
436 $anchorclose .
"</div>\n" );
440 $count = $this->displayImg->pageCount();
443 $label =
$out->parse( $this->
getContext()->msg(
'imgmultipageprev' )->
text(),
false );
450 [
'page' =>
$page - 1 ]
458 [
'page' =>
$page - 1 ]
465 $label = $this->
getContext()->msg(
'imgmultipagenext' )->text();
470 [
'page' =>
$page + 1 ]
478 [
'page' =>
$page + 1 ]
487 'name' =>
'pageselector',
491 for ( $i = 1; $i <=
$count; $i++ ) {
495 [
'id' =>
'pageselector',
'name' =>
'page' ],
499 '</td><td><div class="multipageimagenavbox">' .
502 $this->
getContext()->msg(
'imgmultigoto' )->rawParams( $select )->parse() .
505 "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
508 } elseif ( $this->displayImg->isSafeFile() ) {
509 # if direct link is allowed but it's not a renderable image, show an icon.
510 $icon = $this->displayImg->iconThumb();
512 $out->addHTML(
'<div class="fullImageLink" id="file">' .
513 $icon->toHtml( [
'file-link' =>
true ] ) .
517 $longDesc = $this->
getContext()->msg(
'parentheses', $this->displayImg->getLongDesc() )->
text();
519 $handler = $this->displayImg->getHandler();
523 $warningConfig =
$handler->getWarningConfig( $this->displayImg );
525 if ( $warningConfig !== null ) {
535 $medialink =
"[[Media:$filename|$linktext]]";
537 if ( !$this->displayImg->isSafeFile() ) {
538 $warning = $this->
getContext()->msg(
'mediawarning' )->plain();
547 $out->addWikiText( <<<EOT
548 <div
class=
"fullMedia"><span
class=
"dangerousLink">{$medialink}</span> $dirmark<span
class=
"fileInfo">$longDesc</span></div>
549 <div
class=
"mediaWarning">$warning</div>
554 $out->addWikiText( <<<EOT
555 <div
class=
"fullMedia">{$medialink} {$dirmark}<span
class=
"fileInfo">$longDesc</span>
561 $renderLangOptions = $this->displayImg->getAvailableLanguages();
562 if ( count( $renderLangOptions ) >= 1 ) {
563 $currentLanguage = $renderLang;
564 $defaultLang = $this->displayImg->getDefaultRenderLanguage();
565 if ( is_null( $currentLanguage ) ) {
566 $currentLanguage = $defaultLang;
568 $out->addHTML( $this->
doRenderLangOpt( $renderLangOptions, $currentLanguage, $defaultLang ) );
572 if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
578 $ext = $this->displayImg->getExtension();
580 'file-no-thumb-animation-' .
$ext,
581 'file-no-thumb-animation'
584 $out->addWikiText( <<<EOT
585 <div
class=
"mw-noanimatethumb">{$noAnimMesg}</div>
590 if ( !$this->displayImg->isLocal() ) {
594 # Image does not exist
595 if ( !$this->
getId() ) {
596 # No article exists either
597 # Show deletion log to be consistent with normal articles
600 [
'delete',
'move' ],
601 $this->
getTitle()->getPrefixedText(),
604 'conds' => [
"log_action != 'revision'" ],
605 'showIfEmpty' =>
false,
606 'msgKey' => [
'moveddeleted-notice' ]
611 if ( $wgEnableUploads &&
$user->isAllowed(
'upload' ) ) {
615 'filepage-nofile-link',
616 $uploadTitle->getFullURL( [
'wpDestFile' => $this->mPage->getFile()->getName() ] )
619 $nofile =
'filepage-nofile';
624 $out->setRobotPolicy(
'noindex,nofollow' );
625 $out->wrapWikiMsg(
"<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
626 if ( !$this->
getId() && $wgSend404Code ) {
629 $request->response()->statusHeader( 404 );
632 $out->setFileVersion( $this->displayImg );
643 if ( $sizeLinkBigImagePreview ) {
645 $previewTypeDiffers =
false;
646 $origExt = $thumbExt = $this->displayImg->getExtension();
647 if ( $this->displayImg->getHandler() ) {
648 $origMime = $this->displayImg->getMimeType();
650 $this->displayImg->getHandler()->normaliseParams( $this->displayImg, $typeParams );
651 list( $thumbExt, $thumbMime ) = $this->displayImg->getHandler()->getThumbType(
652 $origExt, $origMime, $typeParams );
653 if ( $thumbMime !== $origMime ) {
654 $previewTypeDiffers =
true;
657 if ( $previewTypeDiffers ) {
658 return $this->
getContext()->msg(
'show-big-image-preview-differ' )->
659 rawParams( $sizeLinkBigImagePreview )->
660 params( strtoupper( $origExt ) )->
661 params( strtoupper( $thumbExt ) )->
664 return $this->
getContext()->msg(
'show-big-image-preview' )->
665 rawParams( $sizeLinkBigImagePreview )->
683 $thumbnail = $this->displayImg->transform(
$params );
684 if ( $thumbnail && !$thumbnail->isError() ) {
686 'href' => $thumbnail->getUrl(),
687 'class' =>
'mw-thumbnail-link'
688 ], $this->
getContext()->msg(
'show-big-image-size' )->numParams(
689 $thumbnail->getWidth(), $thumbnail->getHeight()
703 $descUrl = $this->mPage->getFile()->getDescriptionUrl();
704 $descText = $this->mPage->getFile()->getDescriptionText( $this->
getContext()->getLanguage() );
707 if ( $descUrl && $this->mPage->getId() == 0 ) {
708 $out->setCanonicalUrl( $descUrl );
711 $wrap =
"<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
716 $this->
getContext()->msg(
'sharedupload-desc-here' )->plain() !==
'-'
718 $out->wrapWikiMsg( $wrap, [
'sharedupload-desc-here',
$repo, $descUrl ] );
719 } elseif ( $descUrl &&
720 $this->
getContext()->msg(
'sharedupload-desc-there' )->plain() !==
'-'
722 $out->wrapWikiMsg( $wrap, [
'sharedupload-desc-there',
$repo, $descUrl ] );
724 $out->wrapWikiMsg( $wrap, [
'sharedupload',
$repo ],
'' );
728 $this->mExtraDescription = $descText;
735 return $uploadTitle->getFullURL( [
736 'wpDestFile' => $this->mPage->getFile()->getName(),
748 if ( !$wgEnableUploads ) {
753 if ( !$this->mPage->getFile()->isLocal() ) {
758 $out->addHTML(
"<ul>\n" );
760 # "Upload a new version of this file" link
764 $this->mPage->getFile() )
770 $out->addHTML(
"<li id=\"mw-imagepage-reupload-link\">"
771 .
"<div class=\"plainlinks\">{$ulink}</div></li>\n" );
773 $out->addHTML(
"<li id=\"mw-imagepage-upload-disallowed\">"
774 . $this->
getContext()->msg(
'upload-disallowed-here' )->escaped() .
"</li>\n" );
777 $out->addHTML(
"</ul>\n" );
794 $out->addHTML( $pager->getBody() );
795 $out->preventClickjacking( $pager->getPreventClickjacking() );
797 $this->mPage->getFile()->resetHistory();
799 # Exist check because we don't want to show this on pages where an image
800 # doesn't exist along with the noimage message, that would suck. -ævar
801 if ( $this->mPage->getFile()->exists() ) {
815 [
'imagelinks',
'page' ],
816 [
'page_namespace',
'page_title',
'il_to' ],
817 [
'il_to' => $target,
'il_from = page_id' ],
819 [
'LIMIT' =>
$limit + 1,
'ORDER BY' =>
'il_from', ]
831 $redirects[$redir->getDBkey()] = [];
834 'page_title' => $redir->getDBkey(),
839 foreach (
$res as $row ) {
845 if ( !$hasMore && count( $redirects ) ) {
847 $limit - count( $rows ) + 1 );
848 foreach (
$res as $row ) {
849 $redirects[$row->il_to][] = $row;
852 $hasMore = (
$res->numRows() + count( $rows ) ) > $limit;
858 [
'id' =>
'mw-imagepage-nolinkstoimage' ],
"\n$1\n" ),
864 $out->addHTML(
"<div id='mw-imagepage-section-linkstoimage'>\n" );
869 $out->addWikiMsg(
'linkstoimage-more',
870 $this->
getContext()->getLanguage()->formatNum( $limit ),
871 $this->
getTitle()->getPrefixedDBkey()
877 [
'class' =>
'mw-imagepage-linkstoimage' ] ) .
"\n"
882 usort( $rows, [ $this,
'compare' ] );
886 foreach ( $rows
as $element ) {
888 if ( $currentCount > $limit ) {
893 # Add a redirect=no to make redirect pages reachable
894 if ( isset( $redirects[$element->page_title] ) ) {
895 $query[
'redirect'] =
'no';
901 if ( !isset( $redirects[$element->page_title] ) ) {
904 } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
905 # Redirect without usages
906 $liContents = $this->
getContext()->msg(
'linkstoimage-redirect' )
907 ->rawParams(
$link,
'' )
910 # Redirect with usages
912 foreach ( $redirects[$element->page_title]
as $row ) {
914 if ( $currentCount > $limit ) {
921 [
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
928 [
'class' =>
'mw-imagepage-redirectstofile' ],
931 $liContents = $this->
getContext()->msg(
'linkstoimage-redirect' )->rawParams(
936 [
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
947 $out->addWikiMsg(
'morelinkstoimage', $this->
getTitle()->getPrefixedDBkey() );
956 $dupes = $this->mPage->getDuplicates();
957 if ( count( $dupes ) == 0 ) {
961 $out->addHTML(
"<div id='mw-imagepage-section-duplicates'>\n" );
962 $out->addWikiMsg(
'duplicatesoffile',
963 $this->
getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->
getTitle()->getDBkey()
965 $out->addHTML(
"<ul class='mw-imagepage-duplicates'>\n" );
970 foreach ( $dupes
as $file ) {
972 if ( $file->isLocal() ) {
976 $file->getTitle()->getPrefixedText() );
979 $file->getRepo()->getDisplayName()
982 $out->addHTML(
"<li>{$link} {$fromSrc}</li>\n" );
984 $out->addHTML(
"</ul></div>\n" );
990 public function delete() {
991 $file = $this->mPage->getFile();
992 if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
1009 $out->setPageTitle( $this->
getContext()->msg(
'internalerror' ) );
1010 $out->setRobotPolicy(
'noindex,nofollow' );
1011 $out->setArticleRelated(
false );
1012 $out->enableClientCache(
false );
1013 $out->addWikiText( $description );
1025 if ( $a->page_namespace == $b->page_namespace ) {
1026 return strcmp( $a->page_title, $b->page_title );
1028 return $a->page_namespace - $b->page_namespace;
1043 $option =
$user->getIntOption( $optionName );
1044 if ( !isset( $wgImageLimits[$option] ) ) {
1050 if ( !isset( $wgImageLimits[$option] ) ) {
1055 return isset( $wgImageLimits[$option] )
1056 ? $wgImageLimits[$option]
1070 sort( $langChoices );
1071 $curLang =
wfBCP47( $curLang );
1072 $defaultLang =
wfBCP47( $defaultLang );
1074 $haveCurrentLang =
false;
1075 $haveDefaultLang =
false;
1083 foreach ( $langChoices
as $lang ) {
1086 if (
$name !==
'' ) {
1092 if ( $curLang ===
$code ) {
1093 $haveCurrentLang =
true;
1095 if ( $defaultLang ===
$code ) {
1096 $haveDefaultLang =
true;
1099 if ( !$haveDefaultLang ) {
1105 $defaultLang === $curLang
1108 if ( !$haveCurrentLang && $defaultLang !== $curLang ) {
1110 if (
$name !==
'' ) {
1111 $display = $this->
getContext()->msg(
'img-lang-opt', $curLang,
$name )->text();
1113 $display = $curLang;
1115 $opts =
Xml::option( $display, $curLang,
true ) . $opts;
1120 [
'id' =>
'mw-imglangselector',
'name' =>
'lang' ],
1125 $formContents = $this->
getContext()->msg(
'img-lang-info' )
1126 ->rawParams( $select, $submit )
1130 $langSelectLine =
Html::rawElement(
'div', [
'id' =>
'mw-imglangselector-line' ],
1133 return $langSelectLine;
1151 if ( !$maxWidth || !$maxHeight ) {
1153 throw new MWException(
'Using a choice from $wgImageLimits that is 0x0' );
1156 if ( !$width || !$height ) {
1160 # Calculate the thumbnail size.
1161 if ( $width <= $maxWidth && $height <= $maxHeight ) {
1163 } elseif ( $width / $height >= $maxWidth / $maxHeight ) {
1164 # The limiting factor is the width, not the height.
1165 $height = round( $height * $maxWidth / $width );
1167 # Note that $height <= $maxHeight now.
1169 $newwidth = floor( $width * $maxHeight / $height );
1170 $height = round( $height * $newwidth / $width );
1172 # Note that $height <= $maxHeight now, but might not be identical
1173 # because of rounding.
1175 return [ $width, $height ];
1188 if ( $this->displayImg->getRepo()->canTransformVia404() ) {
1196 $thumbSizes[] = [ $origWidth, $origHeight ];
1198 # Creating thumb links triggers thumbnail generation.
1199 # Just generate the thumb for the current users prefs.
1203 if ( !$this->displayImg->mustRender() ) {
1206 $thumbSizes[] = [ $origWidth, $origHeight ];
1217 return $this->mPage->getFile();
1225 return $this->mPage->isLocal();
1233 return $this->mPage->getDuplicates();
1241 $this->mPage->getForeignCategories();
viewRedirect($target, $appendSubtitle=true, $forceKnown=false)
Return the HTML for the top of a redirect page.
static newFromID($id, $flags=0)
Create a new Title from an article ID.
static closeElement($element)
Returns "$element>".
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
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
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
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
static processResponsiveImages($file, $thumb, $hp)
Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.
the array() calling protocol came about after MediaWiki 1.4rc1.
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
$wgScript
The URL path to index.php.
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
queryImageLinks($target, $limit)
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name.
showTOC($metadata)
Create the TOC.
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
if(!isset($args[0])) $lang
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Class for viewing MediaWiki article and history.
Class for viewing MediaWiki file description pages.
wfMessageFallback()
This function accepts multiple message keys and returns a message instance for the first message whic...
Represents a title within MediaWiki.
when a variable name is used in a it is silently declared as a new local masking the global
printSharedImageText()
Show a notice that the file is from a shared repository.
wfLocalFile($title)
Get an object referring to a locally registered file.
imageHistory()
If the page we've just displayed is in the "Image" namespace, we follow it with an upload history of ...
uploadLinksBox()
Print out the various links at the bottom of the image page, e.g.
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
static submitButton($value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
static userCanReUpload(User $user, File $img)
Check if a user is the last uploader.
static showLogExtract(&$out, $types=[], $page= '', $user= '', $param=[])
Show log extract.
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
getThumbSizes($origWidth, $origHeight)
Get alternative thumbnail sizes.
$wgEnableUploads
Uploads have to be specially set up to be secure.
getContext()
Gets the context this Article is executed in.
static closeElement($element)
Shortcut to close an XML element.
showError($description)
Display an error with a wikitext description.
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
$wgShowEXIF
Show Exif data, on by default if available.
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
static newFromID($id)
Constructor from a page id.
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
static option($text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
static openElement($element, $attribs=null)
This opens an XML element.
$wgImageLimits
Limit images on image description pages to a user-selectable limit.
getTitle()
Get the title object of the article.
wfBCP47($code)
Get the normalised IETF language tag See unit test for examples.
namespace and then decline to actually register it file or subcat img or subcat $title
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
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
render()
Handler for action=render Include body text only; none of the image extras.
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
Special handling for file pages.
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
compare($a, $b)
Callback for usort() to do link sorts by (namespace, title) Function copied from Title::compare() ...
static fetchLanguageName($code, $inLanguage=null, $include= 'all')
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
$wgSVGMaxSize
Don't scale a SVG larger than this.
static escapeId($id, $options=[])
Given a value, escape it so that it can be used in an id attribute and return it. ...
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
static makeExternalLink($url, $text, $escape=true, $linktype= '', $attribs=[], $title=null)
Make an external link.
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
static tags($element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
error also a ContextSource you ll probably need to make sure the header is varied on $request
getId()
Call to WikiPage function for backwards compatibility.
getDisplayWidthHeight($maxWidth, $maxHeight, $width, $height)
Get the width and height to display image at.
getDisplayName()
Get the human-readable name of the repo.
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
makeSizeLink($params, $width, $height)
Creates an thumbnail of specified size and returns an HTML link to it.
addJsConfigVars($keys, $value=null)
Add one or more variables to be set in mw.config in JavaScript.
doRenderLangOpt(array $langChoices, $curLang, $defaultLang)
Output a drop-down box for language options for the file.
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
getThumbPrevText($params, $sizeLinkBigImagePreview)
Make the text under the image to say what size preview.
getUser($audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
static makeThumbLinkObj(Title $title, $file, $label= '', $alt, $align= 'right', $params=[], $framed=false, $manualthumb="")
Make HTML for a thumbnail including image, border and caption.
static getDefaultOption($opt)
Get a given default option value.
$wgSend404Code
Some web hosts attempt to rewrite all responses with a 404 (not found) status code, mangling or hiding MediaWiki's output.
getImageLimitsFromOption($user, $optionName)
Returns the corresponding $wgImageLimits entry for the selected user option.
wfFindFile($title, $options=[])
Find a file.
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
makeMetadataTable($metadata)
Make a table with metadata to be shown in the output page.
getContentObject()
Overloading Article's getContentObject method.
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
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
closeShowImage()
For overloading.
Allows to change the fields on the form that will be generated $name