MediaWiki  master
ImagePage Class Reference

Class for viewing MediaWiki file description pages. More...

Inheritance diagram for ImagePage:
Collaboration diagram for ImagePage:

Public Member Functions

 delete ()
 Delete the file, or an earlier version of it. More...
 
 getDisplayedFile ()
 
 getDuplicates ()
 
 getEmptyPageParserOutput (ParserOptions $options)
 Overloading Article's getEmptyPageParserOutput method. More...
 
 getFile ()
 
 getForeignCategories ()
 
 getImageLimitsFromOption ( $user, $optionName)
 Returns the corresponding $wgImageLimits entry for the selected user option. More...
 
 getUploadUrl ()
 
 isLocal ()
 
 setFile ( $file)
 
 showError ( $description)
 Display an error with a wikitext description. More...
 
 view ()
 This is the default action of the index.php entry point: just view the page of the given title. More...
 
- Public Member Functions inherited from Article
 __construct (Title $title, $oldId=null)
 
 __get ( $fname)
 
 __set ( $fname, $fvalue)
 
 addHelpLink ( $to, $overrideBaseUrl=false)
 Adds help link with an icon via page indicators. More...
 
 adjustDisplayTitle (ParserOutput $pOutput)
 Adjust title for pages with displaytitle, -{T|}- or language conversion. More...
 
 checkFlags ( $flags)
 Call to WikiPage function for backwards compatibility. More...
 
 checkTouched ()
 
 clear ()
 Clear the object. More...
 
 clearPreparedEdit ()
 Call to WikiPage function for backwards compatibility. More...
 
 commitRollback ( $fromP, $summary, $bot, &$resultDetails, User $guser=null)
 
 confirmDelete ( $reason)
 Output deletion confirmation dialog. More...
 
 doDelete ( $reason, $suppress=false, $immediate=false)
 Perform a deletion and output success or failure messages. More...
 
 doDeleteArticle ( $reason, $suppress=false, $u1=null, $u2=null, &$error='', $immediate=false)
 
 doDeleteArticleReal ( $reason, $suppress=false, $u1=null, $u2=null, &$error='', User $user=null, $tags=[], $immediate=false)
 Call to WikiPage function for backwards compatibility. More...
 
 doDeleteUpdates ( $id, Content $content=null, $revision=null, User $user=null)
 
 doEditUpdates (Revision $revision, User $user, array $options=[])
 Call to WikiPage function for backwards compatibility. More...
 
 doPurge ()
 
 doRollback ( $fromP, $summary, $token, $bot, &$resultDetails, User $user=null)
 
 doUpdateRestrictions (array $limit, array $expiry, &$cascade, $reason, User $user)
 
 doViewUpdates (User $user, $oldid=0)
 
 exists ()
 
 fetchRevisionRecord ()
 Fetches the revision to work on. More...
 
 followRedirect ()
 
 generateReason (&$hasHistory)
 
 getActionOverrides ()
 Call to WikiPage function for backwards compatibility. More...
 
 getAutoDeleteReason (&$hasHistory)
 
 getCategories ()
 
 getComment ( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
 Call to WikiPage function for backwards compatibility. More...
 
 getContentHandler ()
 
 getContentModel ()
 
 getContext ()
 Gets the context this Article is executed in. More...
 
 getContributors ()
 
 getCreator ( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
 Call to WikiPage function for backwards compatibility. More...
 
 getDeletionUpdates (Content $content=null)
 
 getHiddenCategories ()
 
 getId ()
 
 getLatest ()
 
 getLinksTimestamp ()
 
 getMinorEdit ()
 
 getOldestRevision ()
 
 getOldID ()
 
 getOldIDFromRequest ()
 Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect. More...
 
 getPage ()
 Get the WikiPage object of this instance. More...
 
 getParserOptions ()
 Get parser options suitable for rendering the primary article wikitext. More...
 
 getParserOutput ( $oldid=null, User $user=null)
 #- More...
 
 getRedirectedFrom ()
 Get the page this view was redirected from. More...
 
 getRedirectTarget ()
 
 getRedirectURL ( $rt)
 
 getRevIdFetched ()
 Use this to fetch the rev ID used on page views. More...
 
 getRevision ()
 Call to WikiPage function for backwards compatibility. More...
 
 getRevisionFetched ()
 Get the fetched Revision object depending on request parameters or null on failure. More...
 
 getRobotPolicy ( $action, ParserOutput $pOutput=null)
 Get the robot policy to be used for the current view. More...
 
 getTimestamp ()
 
 getTitle ()
 Get the title object of the article. More...
 
 getTouched ()
 
 getUndoContent (Revision $undo, Revision $undoafter=null)
 Call to WikiPage function for backwards compatibility. More...
 
 getUser ( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
 
 getUserText ( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
 
 hasViewableContent ()
 
 insertOn ( $dbw, $pageId=null)
 
 insertProtectNullRevision ( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user=null)
 
 insertRedirect ()
 
 insertRedirectEntry (Title $rt, $oldLatest=null)
 
 isCountable ( $editInfo=false)
 
 isCurrent ()
 Returns true if the currently-referenced revision is the current edit to this page (and it exists). More...
 
 isFileCacheable ( $mode=HTMLFileCache::MODE_NORMAL)
 Check if the page can be cached. More...
 
 isRedirect ()
 
 loadFromRow ( $data, $from)
 
 loadPageData ( $from='fromdb')
 
 lockAndGetLatest ()
 
 makeParserOptions ( $context)
 
 pageDataFromId ( $dbr, $id, $options=[])
 
 pageDataFromTitle ( $dbr, $title, $options=[])
 
 prepareContentForEdit (Content $content, $revision=null, User $user=null, $serialFormat=null, $useCache=true)
 Call to WikiPage function for backwards compatibility. More...
 
 protect ()
 action=protect handler More...
 
 protectDescription (array $limit, array $expiry)
 
 protectDescriptionLog (array $limit, array $expiry)
 
 render ()
 Handle action=render. More...
 
 replaceSectionAtRev ( $sectionId, Content $sectionContent, $sectionTitle='', $baseRevId=null)
 
 replaceSectionContent ( $sectionId, Content $sectionContent, $sectionTitle='', $edittime=null)
 Call to WikiPage function for backwards compatibility. More...
 
 setContext ( $context)
 Sets the context this Article is executed in. More...
 
 setOldSubtitle ( $oldid=0)
 Generate the navigation links when browsing through an article revisions It shows the information as: Revision as of \<date\>; view current revision \<- Previous version | Next Version -\> More...
 
 setParserOptions (ParserOptions $options)
 Override the ParserOptions used to render the primary article wikitext. More...
 
 setRedirectedFrom (Title $from)
 Tell the page view functions that this view was redirected from another page on the wiki. More...
 
 setTimestamp ( $ts)
 
 shouldCheckParserCache (ParserOptions $parserOptions, $oldId)
 
 showDeletedRevisionHeader ()
 If the revision requested for view is deleted, check permissions. More...
 
 showMissingArticle ()
 Show the error text for a missing article. More...
 
 showNamespaceHeader ()
 Show a header specific to the namespace currently being viewed, like [[MediaWiki:Talkpagetext]]. More...
 
 showPatrolFooter ()
 If patrol is possible, output a patrol UI box. More...
 
 showRedirectedFromHeader ()
 If this request is a redirect view, send "redirected from" subtitle to the output. More...
 
 showViewFooter ()
 Show the footer section of an ordinary page view. More...
 
 supportsSections ()
 
 triggerOpportunisticLinksUpdate (ParserOutput $parserOutput)
 
 unprotect ()
 action=unprotect handler (alias) More...
 
 updateCategoryCounts (array $added, array $deleted, $id=0)
 
 updateIfNewerOn ( $dbw, $revision)
 Call to WikiPage function for backwards compatibility. More...
 
 updateRedirectOn ( $dbw, $redirectTitle, $lastRevIsRedirect=null)
 
 updateRestrictions ( $limit=[], $reason='', &$cascade=0, $expiry=[])
 
 updateRevisionOn ( $dbw, $revision, $lastRevision=null, $lastRevIsRedirect=null)
 
 viewRedirect ( $target, $appendSubtitle=true, $forceKnown=false)
 Return the HTML for the top of a redirect page. More...
 

Protected Member Functions

 closeShowImage ()
 For overloading. More...
 
 compare ( $a, $b)
 Callback for usort() to do link sorts by (namespace, title) Function copied from Title::compare() More...
 
 doRenderLangOpt (array $langChoices, $renderLang)
 Output a drop-down box for language options for the file. More...
 
 getThumbPrevText ( $params, $sizeLinkBigImagePreview)
 Make the text under the image to say what size preview. More...
 
 getThumbSizes ( $origWidth, $origHeight)
 Get alternative thumbnail sizes. More...
 
 imageDupes ()
 
 imageHistory ()
 If the page we've just displayed is in the "Image" namespace, we follow it with an upload history of the image and its usage. More...
 
 imageLinks ()
 
 loadFile ()
 
 makeMetadataTable ( $metadata)
 Make a table with metadata to be shown in the output page. More...
 
 makeSizeLink ( $params, $width, $height)
 Creates an thumbnail of specified size and returns an HTML link to it. More...
 
 newPage (Title $title)
 
 openShowImage ()
 
 printSharedImageText ()
 Show a notice that the file is from a shared repository. More...
 
 queryImageLinks ( $target, $limit)
 
 showTOC ( $metadata)
 Create the TOC. More...
 
 uploadLinksBox ()
 Add the re-upload link (or message about not being able to re-upload) to the output. More...
 
- Protected Member Functions inherited from Article
 fetchContentObject ()
 Get text content object Does NOT follow redirects. More...
 
 getContentObject ()
 Returns a Content object representing the pages effective display content, not necessarily the revision's content! More...
 
 showDiffPage ()
 Show a diff page according to current request variables. More...
 
 tryFileCache ()
 checkLastModified returns true if it has taken care of all output to the client that is necessary for this request. More...
 

Protected Attributes

bool $mExtraDescription = false
 
- Protected Attributes inherited from Article
LinkRenderer $linkRenderer
 
IContextSource null $mContext
 The context this Article is executed in. More...
 
WikiPage $mPage
 The WikiPage object of this instance. More...
 
bool $viewIsRenderAction = false
 Whether render() was called. More...
 

Private Member Functions

 createXmlOptionStringForLanguage ( $lang, $selected)
 
 getLanguageForRendering (WebRequest $request, File $file)
 Returns language code to be used for dispaying the image, based on request context and languages available in the file. More...
 

Private Attributes

File false $displayImg
 
bool $fileLoaded
 
FileRepo $repo
 

Additional Inherited Members

- Static Public Member Functions inherited from Article
static formatRobotPolicy ( $policy)
 Converts a String robot policy into an associative array, to allow merging of several policies using array_merge(). More...
 
static getRedirectHeaderHtml (Language $lang, $target, $forceKnown=false)
 Return the HTML for the top of a redirect page. More...
 
static newFromID ( $id)
 Constructor from a page id. More...
 
static newFromTitle ( $title, IContextSource $context)
 Create an Article object of the appropriate class for the given page. More...
 
static newFromWikiPage (WikiPage $page, IContextSource $context)
 Create an Article object of the appropriate class for the given page. More...
 
static purgePatrolFooterCache ( $articleID)
 Purge the cache used to check if it is worth showing the patrol footer For example, it is done during re-uploads when file patrol is used. More...
 
- Public Attributes inherited from Article
bool $mContentLoaded = false
 Is the target revision loaded? Set by fetchRevisionRecord(). More...
 
Content null $mContentObject
 Content of the main slot of $this->mRevisionRecord. More...
 
int null $mOldId
 The oldid of the article that was requested to be shown, 0 for the current revision. More...
 
ParserOptions null $mParserOptions
 ParserOptions object for $wgUser articles. More...
 
ParserOutput null false $mParserOutput = null
 The ParserOutput generated for viewing the page, initialized by view(). More...
 
Title null $mRedirectedFrom = null
 Title from which we were redirected here, if any. More...
 
string bool $mRedirectUrl = false
 URL to redirect to or false if none. More...
 
int $mRevIdFetched = 0
 Revision ID of revision that was loaded. More...
 

Detailed Description

Class for viewing MediaWiki file description pages.

@method WikiFilePage getPage()

Definition at line 33 of file ImagePage.php.

Member Function Documentation

◆ closeShowImage()

ImagePage::closeShowImage ( )
protected

For overloading.

Definition at line 800 of file ImagePage.php.

Referenced by view().

◆ compare()

ImagePage::compare (   $a,
  $b 
)
protected

Callback for usort() to do link sorts by (namespace, title) Function copied from Title::compare()

Parameters
object$aObject page to compare with
object$bObject page to compare with
Returns
int Result of string comparison, or namespace comparison

Definition at line 1045 of file ImagePage.php.

◆ createXmlOptionStringForLanguage()

ImagePage::createXmlOptionStringForLanguage (   $lang,
  $selected 
)
private
Parameters
string$lang
bool$selected
Returns
string

Definition at line 1115 of file ImagePage.php.

References $lang, LanguageCode\bcp47(), Article\getContext(), and Xml\option().

Referenced by doRenderLangOpt().

◆ delete()

ImagePage::delete ( )

Delete the file, or an earlier version of it.

Reimplemented from Article.

Definition at line 1010 of file ImagePage.php.

References $file, Article\getContext(), getFile(), and Article\getUser().

◆ doRenderLangOpt()

ImagePage::doRenderLangOpt ( array  $langChoices,
  $renderLang 
)
protected

Output a drop-down box for language options for the file.

Parameters
array$langChoicesArray of string language codes
string$renderLangLanguage code for the language we want the file to rendered in.
Returns
string HTML to insert underneath image.

Definition at line 1070 of file ImagePage.php.

References $lang, $wgScript, createXmlOptionStringForLanguage(), Article\getContext(), Article\getTitle(), Html\hidden(), Xml\option(), Html\rawElement(), and Xml\submitButton().

Referenced by openShowImage().

◆ getDisplayedFile()

ImagePage::getDisplayedFile ( )
Returns
File

Definition at line 225 of file ImagePage.php.

References $displayImg, and loadFile().

Referenced by ImageHistoryList\__construct().

◆ getDuplicates()

ImagePage::getDuplicates ( )
See also
WikiFilePage::getDuplicates
Returns
array|null

Definition at line 1188 of file ImagePage.php.

References Article\getPage().

◆ getEmptyPageParserOutput()

ImagePage::getEmptyPageParserOutput ( ParserOptions  $options)

Overloading Article's getEmptyPageParserOutput method.

Omit noarticletext if sharedupload; text will be fetched from the shared upload server if possible.

Parameters
ParserOptions$options
Returns
ParserOutput

Reimplemented from Article.

Definition at line 293 of file ImagePage.php.

References getFile(), Article\getId(), Article\getPage(), isLocal(), and loadFile().

◆ getFile()

ImagePage::getFile ( )

◆ getForeignCategories()

ImagePage::getForeignCategories ( )
See also
WikiFilePage::getForeignCategories
Returns
TitleArray|Title[]

Definition at line 1196 of file ImagePage.php.

References Article\getPage().

◆ getImageLimitsFromOption()

ImagePage::getImageLimitsFromOption (   $user,
  $optionName 
)

Returns the corresponding $wgImageLimits entry for the selected user option.

Parameters
User$user
string$optionNameName of a option to check, typically imagesize or thumbsize
Returns
int[]
Since
1.21
Deprecated:
Since 1.35 Use static function MediaFileTrait::getImageLimitsFromOption

Definition at line 1059 of file ImagePage.php.

Referenced by getThumbSizes(), and openShowImage().

◆ getLanguageForRendering()

ImagePage::getLanguageForRendering ( WebRequest  $request,
File  $file 
)
private

Returns language code to be used for dispaying the image, based on request context and languages available in the file.

Parameters
WebRequest$request
File$file
Returns
string|null

Definition at line 313 of file ImagePage.php.

References $file, and WebRequest\getVal().

Referenced by openShowImage().

◆ getThumbPrevText()

ImagePage::getThumbPrevText (   $params,
  $sizeLinkBigImagePreview 
)
protected

Make the text under the image to say what size preview.

Parameters
array$paramsparameters for thumbnail
string$sizeLinkBigImagePreviewHTML for the current size
Returns
string HTML output

Definition at line 661 of file ImagePage.php.

References Article\getContext().

Referenced by openShowImage().

◆ getThumbSizes()

ImagePage::getThumbSizes (   $origWidth,
  $origHeight 
)
protected

Get alternative thumbnail sizes.

Note
This will only list several alternatives if thumbnails are rendered on 404
Parameters
int$origWidthActual width of image
int$origHeightActual height of image
Returns
int[][] An array of [width, height] pairs. -return array<int,array{0:int,1:int}>

Definition at line 1142 of file ImagePage.php.

References $wgImageLimits, Article\getContext(), getImageLimitsFromOption(), and Article\getUser().

Referenced by openShowImage().

◆ getUploadUrl()

ImagePage::getUploadUrl ( )

Definition at line 751 of file ImagePage.php.

References getFile(), SpecialPage\getTitleFor(), and loadFile().

Referenced by uploadLinksBox().

◆ imageDupes()

ImagePage::imageDupes ( )
protected

◆ imageHistory()

ImagePage::imageHistory ( )
protected

If the page we've just displayed is in the "Image" namespace, we follow it with an upload history of the image and its usage.

Definition at line 807 of file ImagePage.php.

References Article\exists(), Article\getContext(), getFile(), loadFile(), and uploadLinksBox().

Referenced by view().

◆ imageLinks()

◆ isLocal()

ImagePage::isLocal ( )
See also
WikiFilePage::isLocal
Returns
bool

Definition at line 1180 of file ImagePage.php.

References Article\getPage().

Referenced by getEmptyPageParserOutput(), and uploadLinksBox().

◆ loadFile()

◆ makeMetadataTable()

ImagePage::makeMetadataTable (   $metadata)
protected

Make a table with metadata to be shown in the output page.

Todo:
FIXME: Bad interface, see note on MediaHandler::formatMetadata().
Parameters
array$metadataThe array containing the Exif data
Returns
string The metadata table. This is treated as Wikitext (!)

Definition at line 262 of file ImagePage.php.

References $type, Article\getContext(), and Html\rawElement().

Referenced by view().

◆ makeSizeLink()

ImagePage::makeSizeLink (   $params,
  $width,
  $height 
)
protected

Creates an thumbnail of specified size and returns an HTML link to it.

Parameters
array$paramsScaler parameters
int$width
int$height
Returns
string

Definition at line 699 of file ImagePage.php.

References Html\rawElement().

Referenced by openShowImage().

◆ newPage()

ImagePage::newPage ( Title  $title)
protected
Parameters
Title$title
Returns
WikiFilePage

Reimplemented from Article.

Definition at line 52 of file ImagePage.php.

References $title.

◆ openShowImage()

◆ printSharedImageText()

ImagePage::printSharedImageText ( )
protected

Show a notice that the file is from a shared repository.

Definition at line 718 of file ImagePage.php.

References $repo, Article\getContext(), getFile(), Article\getId(), Article\getPage(), and loadFile().

Referenced by openShowImage().

◆ queryImageLinks()

ImagePage::queryImageLinks (   $target,
  $limit 
)
protected
Parameters
string | string[]$target
int$limit
Returns
IResultWrapper

Definition at line 828 of file ImagePage.php.

References $dbr, DB_REPLICA, and wfGetDB().

Referenced by imageLinks().

◆ setFile()

ImagePage::setFile (   $file)
Parameters
File$file
Returns
void

Definition at line 61 of file ImagePage.php.

References $file, and Article\getPage().

◆ showError()

ImagePage::showError (   $description)

Display an error with a wikitext description.

Parameters
string$description

Definition at line 1028 of file ImagePage.php.

References Article\getContext().

◆ showTOC()

ImagePage::showTOC (   $metadata)
protected

Create the TOC.

Parameters
bool$metadataWhether or not to show the metadata link
Returns
string

Definition at line 236 of file ImagePage.php.

References Article\getContext().

Referenced by view().

◆ uploadLinksBox()

ImagePage::uploadLinksBox ( )
protected

Add the re-upload link (or message about not being able to re-upload) to the output.

Definition at line 763 of file ImagePage.php.

References Html\element(), Article\getContext(), getFile(), Article\getTitle(), getUploadUrl(), Article\getUser(), isLocal(), loadFile(), Linker\makeExternalLink(), Html\rawElement(), and UploadBase\userCanReUpload().

Referenced by imageHistory().

◆ view()

ImagePage::view ( )

Member Data Documentation

◆ $displayImg

File false ImagePage::$displayImg
private

Definition at line 37 of file ImagePage.php.

Referenced by getDisplayedFile().

◆ $fileLoaded

bool ImagePage::$fileLoaded
private

Definition at line 43 of file ImagePage.php.

◆ $mExtraDescription

bool ImagePage::$mExtraDescription = false
protected

Definition at line 46 of file ImagePage.php.

◆ $repo

FileRepo ImagePage::$repo
private

Definition at line 40 of file ImagePage.php.

Referenced by printSharedImageText().


The documentation for this class was generated from the following file: