/**
* Handler for action=render
* Include body text only; none of the image extras
+ * However, also include the shared description text
+ * so that cascading ForeignAPIRepo's work.
+ *
+ * @note This uses a div with the class "mw-shared-image-desc"
+ * as opposed to the id "mw-shared-image-desc" since the text
+ * from here may be cascadingly transcluded to other shared
+ * repos, and we want all ids to be unique. On normal
+ * view, the outermost shared description will still have
+ * the id.
+ *
+ * This also differs from normal view in that "shareddescriptionfollows"
+ * message is not shown. I was not sure if it was appropriate to
+ * add that message here.
*/
public function render() {
- $this->getContext()->getOutput()->setArticleBodyOnly( true );
- parent::view();
+ $out = $this->getContext()->getOutput();
+ $this->loadFile();
+
+ $descText = $this->mPage->getFile()->getDescriptionText();
+
+ $out->setArticleBodyOnly( true );
+
+ if ( !$descText ) {
+ // If no description text, just do standard action=render
+ parent::view();
+ } else {
+ if ( $this->mPage->getID() !== 0 ) {
+ // Local description exists. We need to output both
+ parent::view();
+ $out->addHTML( '<div class="mw-shared-image-desc">' . $descText . "</div>\n" );
+ } else {
+ // We don't want to output both a "noarticletext" message and the shared
+ // description, so don't call parent::view().
+ $out->addHTML( '<div class="mw-shared-image-desc">' . $descText . "</div>\n" );
+ // Since we did not call parent::view(), have to call some methods it
+ // normally takes care of. (Not that it matters much since skin not displayed)
+ $out->setArticleFlag( true );
+ $out->setPageTitle( $this->getTitle()->getPrefixedText() );
+ $this->mPage->doViewUpdates( $this->getContext()->getUser() );
+ }
+ }
}
public function view() {
$out->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content',
'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
'class' => 'mw-content-'.$pageLang->getDir() ) ) );
+
parent::view();
+
$out->addHTML( Xml::closeElement( 'div' ) );
} else {
# Just need to set the right headers
if ( !$fol->isDisabled() ) {
$out->addWikiText( $fol->plain() );
}
- $out->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
+ $out->addHTML( '<div id="shared-image-desc" class="mw-shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
}
$this->closeShowImage();
$out->addHTML( Xml::element( 'h2',
array( 'id' => 'filelinks' ),
- wfMsg( 'imagelinks' ) ) . "\n" );
+ wfMessage( 'imagelinks' )->text() ) . "\n" );
$this->imageDupes();
# @todo FIXME: For some freaky reason, we can't redirect to foreign images.
# Yet we return metadata about the target. Definitely an issue in the FileRepo
}
if ( $showmeta ) {
- $out->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ) . "\n" );
+ $out->addHTML( Xml::element(
+ 'h2',
+ array( 'id' => 'metadata' ),
+ wfMessage( 'metadata' )->text() ) . "\n" );
$out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
$out->addModules( array( 'mediawiki.action.view.metadata' ) );
}
*/
protected function showTOC( $metadata ) {
$r = array(
- '<li><a href="#file">' . wfMsgHtml( 'file-anchor-link' ) . '</a></li>',
- '<li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>',
- '<li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>',
+ '<li><a href="#file">' . wfMessage( 'file-anchor-link' )->escaped() . '</a></li>',
+ '<li><a href="#filehistory">' . wfMessage( 'filehist' )->escaped() . '</a></li>',
+ '<li><a href="#filelinks">' . wfMessage( 'imagelinks' )->escaped() . '</a></li>',
);
if ( $metadata ) {
- $r[] = '<li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>';
+ $r[] = '<li><a href="#metadata">' . wfMessage( 'metadata' )->escaped() . '</a></li>';
}
wfRunHooks( 'ImagePageShowTOC', array( $this, &$r ) );
*/
protected function makeMetadataTable( $metadata ) {
$r = "<div class=\"mw-imagepage-section-metadata\">";
- $r .= wfMsgNoTrans( 'metadata-help' );
+ $r .= wfMessage( 'metadata-help' )->plain();
$r .= "<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
foreach ( $metadata as $type => $stuff ) {
foreach ( $stuff as $v ) {
}
/**
- * Overloading Article's getContent method.
+ * Overloading Article's getContentObject method.
*
* Omit noarticletext if sharedupload; text will be fetched from the
* shared upload server if possible.
* @return string
*/
- public function getContent() {
+ public function getContentObject() {
$this->loadFile();
if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getID() ) {
- return '';
+ return null;
}
- return parent::getContent();
+ return parent::getContentObject();
}
protected function openShowImage() {
$height_orig = $this->displayImg->getHeight( $page );
$height = $height_orig;
- $longDesc = wfMsg( 'parentheses', $this->displayImg->getLongDesc() );
+ $longDesc = wfMessage( 'parentheses', $this->displayImg->getLongDesc() )->text();
wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$out ) );
# image
# "Download high res version" link below the image
- # $msgsize = wfMsgHtml( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime );
+ # $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
# We'll show a thumbnail of this image
if ( $width > $maxWidth || $height > $maxHeight ) {
# Calculate the thumbnail size.
# Note that $height <= $maxHeight now, but might not be identical
# because of rounding.
}
- $msgbig = wfMsgHtml( 'show-big-image' );
+ $msgbig = wfMessage( 'show-big-image' )->escaped();
if ( $this->displayImg->getRepo()->canTransformVia404() ) {
$thumbSizes = $wgImageLimits;
} else {
$count = $this->displayImg->pageCount();
if ( $page > 1 ) {
- $label = $out->parse( wfMsg( 'imgmultipageprev' ), false );
+ $label = $out->parse( wfMessage( 'imgmultipageprev' )->text(), false );
$link = Linker::linkKnown(
$this->getTitle(),
$label,
}
if ( $page < $count ) {
- $label = wfMsg( 'imgmultipagenext' );
+ $label = wfMessage( 'imgmultipagenext' )->text();
$link = Linker::linkKnown(
$this->getTitle(),
$label,
'</td><td><div class="multipageimagenavbox">' .
Xml::openElement( 'form', $formParams ) .
Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
- wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) .
- Xml::submitButton( wfMsg( 'imgmultigo' ) ) .
+ wfMessage( 'imgmultigoto' )->rawParams( $select )->parse() .
+ Xml::submitButton( wfMessage( 'imgmultigo' )->text() ) .
Xml::closeElement( 'form' ) .
"<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
);
$medialink = "[[Media:$filename|$linktext]]";
if ( !$this->displayImg->isSafeFile() ) {
- $warning = wfMsgNoTrans( 'mediawarning' );
+ $warning = wfMessage( 'mediawarning' )->plain();
// dirmark is needed here to separate the file name, which
// most likely ends in Latin characters, from the description,
// which may begin with the file type. In RTL environment
}
}
+ // Add cannot animate thumbnail warning
+ if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
+ // Include the extension so wiki admins can
+ // customize it on a per file-type basis
+ // (aka say things like use format X instead).
+ // additionally have a specific message for
+ // file-no-thumb-animation-gif
+ $ext = $this->displayImg->getExtension();
+ $noAnimMesg = wfMessageFallback(
+ 'file-no-thumb-animation-' . $ext,
+ 'file-no-thumb-animation'
+ )->plain();
+
+ $out->addWikiText( <<<EOT
+<div class="mw-noanimatethumb">{$noAnimMesg}</div>
+EOT
+ );
+ }
+
if ( !$this->displayImg->isLocal() ) {
$this->printSharedImageText();
}
$wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
$repo = $this->mPage->getFile()->getRepo()->getDisplayName();
- if ( $descUrl && $descText && wfMsgNoTrans( 'sharedupload-desc-here' ) !== '-' ) {
+ if ( $descUrl && $descText && wfMessage( 'sharedupload-desc-here' )->plain() !== '-' ) {
$out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) );
- } elseif ( $descUrl && wfMsgNoTrans( 'sharedupload-desc-there' ) !== '-' ) {
+ } elseif ( $descUrl && wfMessage( 'sharedupload-desc-there' )->plain() !== '-' ) {
$out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) );
} else {
$out->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ );
}
$out = $this->getContext()->getOutput();
- $out->addHTML( "<br /><ul>\n" );
+ $out->addHTML( "<ul>\n" );
# "Upload a new version of this file" link
- if ( UploadBase::userCanReUpload( $this->getContext()->getUser(), $this->mPage->getFile()->name ) ) {
- $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
+ $canUpload = $this->getTitle()->userCan( 'upload', $this->getContext()->getUser() );
+ if ( $canUpload && UploadBase::userCanReUpload( $this->getContext()->getUser(), $this->mPage->getFile()->name ) ) {
+ $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMessage( 'uploadnewversion-linktext' )->text() );
$out->addHTML( "<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" );
+ } else {
+ $out->addHTML( "<li id=\"mw-imagepage-upload-disallowed\">" . $this->getContext()->msg( 'upload-disallowed-here' )->escaped() . "</li>\n" );
}
# External editing link
if ( $wgUseExternalEditor ) {
$elink = Linker::linkKnown(
$this->getTitle(),
- wfMsgHtml( 'edit-externally' ),
+ wfMessage( 'edit-externally' )->escaped(),
array(),
array(
'action' => 'edit',
);
$out->addHTML(
'<li id="mw-imagepage-edit-external">' . $elink . ' <small>' .
- wfMsgExt( 'edit-externally-help', array( 'parseinline' ) ) .
- "</small></li>\n"
+ wfMessage( 'edit-externally-help' )->parse() .
+ "</small></li>\n"
);
}
$link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
$ul .= Html::rawElement(
'li',
- array( 'id' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
+ array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
$link2
) . "\n";
}
}
$out->addHTML( Html::rawElement(
'li',
- array( 'id' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
+ array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
$liContents
) . "\n"
);
} else {
$link = Linker::makeExternalLink( $file->getDescriptionUrl(),
$file->getTitle()->getPrefixedText() );
- $fromSrc = wfMsg( 'shared-repo-from', $file->getRepo()->getDisplayName() );
+ $fromSrc = wfMessage( 'shared-repo-from', $file->getRepo()->getDisplayName() )->text();
}
$out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
}