$this->dupes = null;
$this->repo = null;
}
-
+
+ /**
+ * @param $file File:
+ * @return void
+ */
public function setFile( $file ) {
$this->displayImg = $file;
$this->img = $file;
$diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
if ( $this->mTitle->getNamespace() != NS_FILE || ( isset( $diff ) && $diffOnly ) ) {
- return Article::view();
+ return parent::view();
}
$this->loadFile();
// mTitle is the same as the redirect target so ask Article
// to perform the redirect for us.
$wgRequest->setVal( 'diffonly', 'true' );
- return Article::view();
+ return parent::view();
} else {
// mTitle is not the same as the redirect target so it is
// probably the redirect page itself. Fake the redirect symbol
# No need to display noarticletext, we use our own message, output in openShowImage()
if ( $this->getID() ) {
- Article::view();
+ parent::view();
} else {
# Just need to set the right headers
$wgOut->setArticleFlag( true );
$wgOut->addHTML( $html );
if ( $showmeta ) {
- global $wgStylePath, $wgStyleVersion;
- $expand = htmlspecialchars( Xml::escapeJsString( wfMsg( 'metadata-expand' ) ) );
- $collapse = htmlspecialchars( Xml::escapeJsString( wfMsg( 'metadata-collapse' ) ) );
$wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ) . "\n" );
$wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
- $wgOut->addScriptFile( 'metadata.js' );
- $wgOut->addHTML(
- "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
+ $wgOut->addModules( array( 'mediawiki.legacy.metadata' ) );
+ }
+
+ $css = $this->repo->getDescriptionStylesheetUrl();
+ if ( $css ) {
+ $wgOut->addStyle( $css );
}
}
/**
* Create the TOC
*
- * @param bool $metadata Whether or not to show the metadata link
- * @return string
+ * @param $metadata Boolean: whether or not to show the metadata link
+ * @return String
*/
protected function showTOC( $metadata ) {
$r = array(
*
* FIXME: bad interface, see note on MediaHandler::formatMetadata().
*
- * @param array $exif The array containing the EXIF data
- * @return string
+ * @param $metadata Array: the array containing the EXIF data
+ * @return String
*/
protected function makeMetadataTable( $metadata ) {
$r = "<div class=\"mw-imagepage-section-metadata\">";
if ( $this->img && !$this->img->isLocal() && 0 == $this->getID() ) {
return '';
}
- return Article::getContent();
+ return parent::getContent();
}
protected function openShowImage() {
$this->loadFile();
- $full_url = $this->displayImg->getURL();
- $linkAttribs = false;
$sizeSel = intval( $wgUser->getOption( 'imagesize' ) );
if ( !isset( $wgImageLimits[$sizeSel] ) ) {
$sizeSel = User::getDefaultOption( 'imagesize' );
} else {
$params = array( 'page' => $page );
}
- $width_orig = $this->displayImg->getWidth();
+ $width_orig = $this->displayImg->getWidth( $page );
$width = $width_orig;
- $height_orig = $this->displayImg->getHeight();
+ $height_orig = $this->displayImg->getHeight( $page );
$height = $height_orig;
- $mime = $this->displayImg->getMimeType();
- $showLink = false;
- $linkAttribs = array( 'href' => $full_url );
+
$longDesc = $this->displayImg->getLongDesc();
wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$wgOut ) );
);
} else {
# Image is small enough to show full size on image page
- $msgbig = htmlspecialchars( $this->displayImg->getName() );
$msgsmall = wfMsgExt( 'file-nohires', array( 'parseinline' ) );
}
$params['width'] = $width;
$thumbnail = $this->displayImg->transform( $params );
- $anchorclose = "<br />";
- if ( $this->displayImg->mustRender() ) {
- $showLink = true;
- } else {
- $anchorclose .=
- $msgsmall .
- '<br />' . Xml::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc;
+ $showLink = true;
+ $anchorclose = '';
+ if ( !$this->displayImg->mustRender() ) {
+ $anchorclose = "<br />" . $msgsmall;
}
$isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
'onchange' => 'document.pageselector.submit();',
);
- $option = array();
for ( $i = 1; $i <= $count; $i++ ) {
$options[] = Xml::option( $wgLang->formatNum( $i ), $i, $i == $page );
}
$wgOut->addHTML(
'</td><td><div class="multipageimagenavbox">' .
Xml::openElement( 'form', $formParams ) .
- Xml::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
+ Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) .
Xml::submitButton( wfMsg( 'imgmultigo' ) ) .
Xml::closeElement( 'form' ) .
if ( $showLink ) {
$filename = wfEscapeWikiText( $this->displayImg->getName() );
- $medialink = "[[Media:$filename|$filename]]";
+ $linktext = $filename;
+ if ( isset( $msgbig ) ) {
+ $linktext = wfEscapeWikiText( $msgbig );
+ }
+ $medialink = "[[Media:$filename|$linktext]]";
if ( !$this->displayImg->isSafeFile() ) {
$warning = wfMsgNoTrans( 'mediawarning' );
$wgOut->addWikiText( <<<EOT
-<div class="fullMedia">
-<span class="dangerousLink">{$medialink}</span>$dirmark
-<span class="fileInfo">$longDesc</span>
-</div>
+<div class="fullMedia"><span class="dangerousLink">{$medialink}</span>$dirmark <span class="fileInfo">$longDesc</span></div>
<div class="mediaWarning">$warning</div>
EOT
);
} else {
$wgOut->addWikiText( <<<EOT
-<div class="fullMedia">
-{$medialink}{$dirmark}
-<span class="fileInfo">$longDesc</span>
+<div class="fullMedia">{$medialink}{$dirmark} <span class="fileInfo">$longDesc</span>
</div>
EOT
);
$descUrl = $this->img->getDescriptionUrl();
$descText = $this->img->getDescriptionText();
+ /* Add canonical to head if there is no local page for this shared file */
+ if( $descUrl && $this->getID() == 0 ) {
+ $wgOut->addLink( array( 'rel' => 'canonical', 'href' => $descUrl ) );
+ }
+
$wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
$repo = $this->img->getRepo()->getDisplayName();
- $msg = '';
if ( $descUrl && $descText && wfMsgNoTrans( 'sharedupload-desc-here' ) !== '-' ) {
$wgOut->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) );
} elseif ( $descUrl && wfMsgNoTrans( 'sharedupload-desc-there' ) !== '-' ) {
$sk = $wgUser->getSkin();
$count = 0;
$elements = array();
- while ( $s = $res->fetchObject() ) {
+ foreach ( $res as $s ) {
$count++;
if ( $count <= $limit ) {
// We have not yet reached the extra one that tells us there is more to fetch
$this->loadFile();
if ( !$this->img->exists() || !$this->img->isLocal() || $this->img->getRedirected() ) {
// Standard article deletion
- Article::delete();
+ parent::delete();
return;
}
$deleter = new FileDeleteForm( $this->img );
}
public function imageHistoryLine( $iscur, $file ) {
- global $wgUser, $wgLang, $wgContLang;
+ global $wgUser, $wgLang;
$timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
$img = $iscur ? $file->getName() : $file->getArchiveName();
$description = $file->getDescription();
$local = $this->current->isLocal();
- $row = $css = $selected = '';
+ $row = $selected = '';
// Deletion link
if ( $local && ( $wgUser->isAllowed( 'delete' ) || $wgUser->isAllowed( 'deletedhistory' ) ) ) {
}
$row .= '</td>';
+ $rowClass = null;
wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) );
$classAttr = $rowClass ? " class='$rowClass'" : "";