2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2012-05-12 20:33:02 +00:00
|
|
|
/**
|
|
|
|
|
* Special handling for file description pages.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Class for viewing MediaWiki file description pages
|
2007-04-24 06:53:31 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Media
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-09-01 09:59:53 +00:00
|
|
|
class ImagePage extends Article {
|
|
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
|
|
|
|
* @var File
|
|
|
|
|
*/
|
2011-04-18 19:03:14 +00:00
|
|
|
private $displayImg;
|
2011-06-29 00:08:25 +00:00
|
|
|
/**
|
|
|
|
|
* @var FileRepo
|
|
|
|
|
*/
|
2011-04-18 19:03:14 +00:00
|
|
|
private $repo;
|
|
|
|
|
private $fileLoaded;
|
2011-03-05 17:01:33 +00:00
|
|
|
|
2005-07-04 02:59:23 +00:00
|
|
|
var $mExtraDescription = false;
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
|
|
|
|
* @param $title Title
|
|
|
|
|
* @return WikiFilePage
|
|
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
protected function newPage( Title $title ) {
|
|
|
|
|
// Overload mPage with a file-specific page
|
|
|
|
|
return new WikiFilePage( $title );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor from a page id
|
|
|
|
|
* @param $id Int article ID to load
|
2012-04-30 14:43:03 +00:00
|
|
|
* @return ImagePage|null
|
2011-06-29 22:09:51 +00:00
|
|
|
*/
|
|
|
|
|
public static function newFromID( $id ) {
|
|
|
|
|
$t = Title::newFromID( $id );
|
|
|
|
|
# @todo FIXME: Doesn't inherit right
|
|
|
|
|
return $t == null ? null : new self( $t );
|
|
|
|
|
# return $t == null ? null : new static( $t ); // PHP 5.3
|
2008-05-20 03:26:59 +00:00
|
|
|
}
|
2010-11-15 15:49:52 +00:00
|
|
|
|
|
|
|
|
/**
|
2012-01-12 19:41:18 +00:00
|
|
|
* @param $file File:
|
|
|
|
|
* @return void
|
2010-11-15 15:49:52 +00:00
|
|
|
*/
|
2008-12-15 23:51:28 +00:00
|
|
|
public function setFile( $file ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->mPage->setFile( $file );
|
2008-12-15 23:51:28 +00:00
|
|
|
$this->displayImg = $file;
|
|
|
|
|
$this->fileLoaded = true;
|
|
|
|
|
}
|
2008-05-23 09:03:49 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
protected function loadFile() {
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->fileLoaded ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
return;
|
2008-05-20 03:26:59 +00:00
|
|
|
}
|
2008-05-23 09:03:49 +00:00
|
|
|
$this->fileLoaded = true;
|
|
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->displayImg = $img = false;
|
|
|
|
|
wfRunHooks( 'ImagePageFindFile', array( $this, &$img, &$this->displayImg ) );
|
|
|
|
|
if ( !$img ) { // not set by hook?
|
|
|
|
|
$img = wfFindFile( $this->getTitle() );
|
|
|
|
|
if ( !$img ) {
|
|
|
|
|
$img = wfLocalFile( $this->getTitle() );
|
2008-05-21 22:20:07 +00:00
|
|
|
}
|
2008-05-23 09:03:49 +00:00
|
|
|
}
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->mPage->setFile( $img );
|
|
|
|
|
if ( !$this->displayImg ) { // not set by hook?
|
|
|
|
|
$this->displayImg = $img;
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->repo = $img->getRepo();
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-13 00:29:20 +00:00
|
|
|
/**
|
|
|
|
|
* Handler for action=render
|
|
|
|
|
* Include body text only; none of the image extras
|
2012-08-19 16:21:47 +00:00
|
|
|
* 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.
|
2006-01-13 00:29:20 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function render() {
|
2012-08-19 16:21:47 +00:00
|
|
|
$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() );
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-03 04:56:53 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
public function view() {
|
2012-04-30 14:43:03 +00:00
|
|
|
global $wgShowEXIF;
|
2010-06-09 21:09:13 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
|
|
|
|
$request = $this->getContext()->getRequest();
|
|
|
|
|
$diff = $request->getVal( 'diff' );
|
|
|
|
|
$diffOnly = $request->getBool( 'diffonly', $this->getContext()->getUser()->getOption( 'diffonly' ) );
|
2010-06-09 21:09:13 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->getTitle()->getNamespace() != NS_FILE || ( isset( $diff ) && $diffOnly ) ) {
|
2012-04-27 15:40:14 +00:00
|
|
|
parent::view();
|
|
|
|
|
return;
|
2010-06-09 21:09:13 +00:00
|
|
|
}
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2004-01-12 00:55:01 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->getTitle()->getNamespace() == NS_FILE && $this->mPage->getFile()->getRedirected() ) {
|
|
|
|
|
if ( $this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || isset( $diff ) ) {
|
2008-05-14 11:52:59 +00:00
|
|
|
// mTitle is the same as the redirect target so ask Article
|
|
|
|
|
// to perform the redirect for us.
|
2012-04-30 14:43:03 +00:00
|
|
|
$request->setVal( 'diffonly', 'true' );
|
2012-04-27 15:40:14 +00:00
|
|
|
parent::view();
|
|
|
|
|
return;
|
2008-05-11 19:49:08 +00:00
|
|
|
} else {
|
2011-06-30 01:24:54 +00:00
|
|
|
// mTitle is not the same as the redirect target so it is
|
2008-05-14 11:52:59 +00:00
|
|
|
// probably the redirect page itself. Fake the redirect symbol
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->setPageTitle( $this->getTitle()->getPrefixedText() );
|
|
|
|
|
$out->addHTML( $this->viewRedirect( Title::makeTitle( NS_FILE, $this->mPage->getFile()->getName() ),
|
2008-08-02 02:39:09 +00:00
|
|
|
/* $appendSubtitle */ true, /* $forceKnown */ true ) );
|
2011-12-14 18:33:51 +00:00
|
|
|
$this->mPage->doViewUpdates( $this->getContext()->getUser() );
|
2008-05-11 19:49:08 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-05-08 20:55:13 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $wgShowEXIF && $this->displayImg->exists() ) {
|
2011-05-17 22:03:20 +00:00
|
|
|
// @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
|
2008-05-21 21:33:58 +00:00
|
|
|
$formattedMetadata = $this->displayImg->formatMetadata();
|
2007-07-28 01:15:35 +00:00
|
|
|
$showmeta = $formattedMetadata !== false;
|
2007-01-17 05:01:54 +00:00
|
|
|
} else {
|
|
|
|
|
$showmeta = false;
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( !$diff && $this->displayImg->exists() ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( $this->showTOC( $showmeta ) );
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( !$diff ) {
|
2009-01-02 19:11:34 +00:00
|
|
|
$this->openShowImage();
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2005-07-04 02:59:23 +00:00
|
|
|
|
2007-01-17 05:01:54 +00:00
|
|
|
# No need to display noarticletext, we use our own message, output in openShowImage()
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->mPage->getID() ) {
|
2011-07-06 02:26:06 +00:00
|
|
|
# NS_FILE is in the user language, but this section (the actual wikitext)
|
|
|
|
|
# should be in page content language
|
2012-06-02 18:07:46 +00:00
|
|
|
$pageLang = $this->getTitle()->getPageViewLanguage();
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content',
|
2012-06-02 18:46:21 +00:00
|
|
|
'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
|
2011-06-24 23:01:49 +00:00
|
|
|
'class' => 'mw-content-'.$pageLang->getDir() ) ) );
|
2010-07-25 20:52:30 +00:00
|
|
|
parent::view();
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( Xml::closeElement( 'div' ) );
|
2007-01-17 05:01:54 +00:00
|
|
|
} else {
|
|
|
|
|
# Just need to set the right headers
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->setArticleFlag( true );
|
|
|
|
|
$out->setPageTitle( $this->getTitle()->getPrefixedText() );
|
2011-12-14 18:32:36 +00:00
|
|
|
$this->mPage->doViewUpdates( $this->getContext()->getUser() );
|
2007-01-17 05:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Show shared description, if needed
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->mExtraDescription ) {
|
2011-01-14 10:51:05 +00:00
|
|
|
$fol = wfMessage( 'shareddescriptionfollows' );
|
|
|
|
|
if ( !$fol->isDisabled() ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addWikiText( $fol->plain() );
|
2007-01-17 05:01:54 +00:00
|
|
|
}
|
2012-08-19 16:21:47 +00:00
|
|
|
$out->addHTML( '<div id="shared-image-desc" class="mw-shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
|
2007-01-17 05:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->closeShowImage();
|
|
|
|
|
$this->imageHistory();
|
2008-05-14 15:11:48 +00:00
|
|
|
// TODO: Cleanup the following
|
2010-03-20 22:58:48 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( Xml::element( 'h2',
|
2008-08-08 21:31:38 +00:00
|
|
|
array( 'id' => 'filelinks' ),
|
2012-08-19 20:44:29 +00:00
|
|
|
wfMessage( 'imagelinks' )->text() ) . "\n" );
|
2008-05-14 15:11:48 +00:00
|
|
|
$this->imageDupes();
|
2011-05-17 22:03:20 +00:00
|
|
|
# @todo FIXME: For some freaky reason, we can't redirect to foreign images.
|
2009-02-25 22:18:44 +00:00
|
|
|
# Yet we return metadata about the target. Definitely an issue in the FileRepo
|
2008-05-15 19:17:21 +00:00
|
|
|
$this->imageLinks();
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2009-11-07 09:31:16 +00:00
|
|
|
# Allow extensions to add something after the image links
|
|
|
|
|
$html = '';
|
|
|
|
|
wfRunHooks( 'ImagePageAfterImageLinks', array( $this, &$html ) );
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( $html ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( $html );
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2007-01-17 05:01:54 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $showmeta ) {
|
2012-08-19 20:44:29 +00:00
|
|
|
$out->addHTML( Xml::element(
|
|
|
|
|
'h2',
|
|
|
|
|
array( 'id' => 'metadata' ),
|
|
|
|
|
wfMessage( 'metadata' )->text() ) . "\n" );
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
|
|
|
|
|
$out->addModules( array( 'mediawiki.action.view.metadata' ) );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2011-06-29 00:08:25 +00:00
|
|
|
|
|
|
|
|
// Add remote Filepage.css
|
|
|
|
|
if( !$this->repo->isLocal() ) {
|
|
|
|
|
$css = $this->repo->getDescriptionStylesheetUrl();
|
|
|
|
|
if ( $css ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addStyle( $css );
|
2011-06-29 00:08:25 +00:00
|
|
|
}
|
2010-07-02 19:54:46 +00:00
|
|
|
}
|
2011-06-29 00:08:25 +00:00
|
|
|
// always show the local local Filepage.css, bug 29277
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addModuleStyles( 'filepage' );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2011-03-05 17:01:33 +00:00
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @return File
|
|
|
|
|
*/
|
2008-05-21 21:33:58 +00:00
|
|
|
public function getDisplayedFile() {
|
|
|
|
|
$this->loadFile();
|
|
|
|
|
return $this->displayImg;
|
|
|
|
|
}
|
2005-04-29 19:45:49 +00:00
|
|
|
|
2005-05-05 02:39:21 +00:00
|
|
|
/**
|
|
|
|
|
* Create the TOC
|
|
|
|
|
*
|
2010-07-02 21:22:38 +00:00
|
|
|
* @param $metadata Boolean: whether or not to show the metadata link
|
|
|
|
|
* @return String
|
2005-05-05 02:39:21 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function showTOC( $metadata ) {
|
2009-11-08 11:09:20 +00:00
|
|
|
$r = array(
|
2012-08-19 20:44:29 +00:00
|
|
|
'<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>',
|
2009-11-08 11:09:20 +00:00
|
|
|
);
|
|
|
|
|
if ( $metadata ) {
|
2012-08-19 20:44:29 +00:00
|
|
|
$r[] = '<li><a href="#metadata">' . wfMessage( 'metadata' )->escaped() . '</a></li>';
|
2009-11-08 11:09:20 +00:00
|
|
|
}
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2009-11-08 11:09:20 +00:00
|
|
|
wfRunHooks( 'ImagePageShowTOC', array( $this, &$r ) );
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2009-11-08 11:09:20 +00:00
|
|
|
return '<ul id="filetoc">' . implode( "\n", $r ) . '</ul>';
|
2005-04-29 19:45:49 +00:00
|
|
|
}
|
2005-04-21 11:28:56 +00:00
|
|
|
|
2005-05-05 02:39:21 +00:00
|
|
|
/**
|
|
|
|
|
* Make a table with metadata to be shown in the output page.
|
|
|
|
|
*
|
2011-05-17 22:03:20 +00:00
|
|
|
* @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
*
|
2010-07-02 21:22:38 +00:00
|
|
|
* @param $metadata Array: the array containing the EXIF data
|
2011-04-16 01:23:15 +00:00
|
|
|
* @return String The metadata table. This is treated as Wikitext (!)
|
2005-05-05 02:39:21 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function makeMetadataTable( $metadata ) {
|
2009-05-25 14:02:54 +00:00
|
|
|
$r = "<div class=\"mw-imagepage-section-metadata\">";
|
2012-08-19 20:44:29 +00:00
|
|
|
$r .= wfMessage( 'metadata-help' )->plain();
|
2009-03-28 16:41:00 +00:00
|
|
|
$r .= "<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
|
2007-07-28 01:15:35 +00:00
|
|
|
foreach ( $metadata as $type => $stuff ) {
|
2007-08-21 03:57:54 +00:00
|
|
|
foreach ( $stuff as $v ) {
|
2011-05-17 22:03:20 +00:00
|
|
|
# @todo FIXME: Why is this using escapeId for a class?!
|
2007-07-28 01:15:35 +00:00
|
|
|
$class = Sanitizer::escapeId( $v['id'] );
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $type == 'collapsed' ) {
|
2007-07-28 01:15:35 +00:00
|
|
|
$class .= ' collapsable';
|
|
|
|
|
}
|
2009-03-28 16:41:00 +00:00
|
|
|
$r .= "<tr class=\"$class\">\n";
|
|
|
|
|
$r .= "<th>{$v['name']}</th>\n";
|
|
|
|
|
$r .= "<td>{$v['value']}</td>\n</tr>";
|
2005-11-28 23:56:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-03-28 16:41:00 +00:00
|
|
|
$r .= "</table>\n</div>\n";
|
2005-11-28 23:56:35 +00:00
|
|
|
return $r;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-05-20 22:41:17 +00:00
|
|
|
/**
|
|
|
|
|
* Overloading Article's getContent method.
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
2006-01-13 00:29:20 +00:00
|
|
|
* Omit noarticletext if sharedupload; text will be fetched from the
|
|
|
|
|
* shared upload server if possible.
|
2011-10-29 01:53:28 +00:00
|
|
|
* @return string
|
2005-05-20 22:41:17 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getContent() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getID() ) {
|
2005-05-20 22:41:17 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
2010-11-28 16:05:41 +00:00
|
|
|
return parent::getContent();
|
2005-05-20 22:41:17 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function openShowImage() {
|
2012-04-30 14:43:03 +00:00
|
|
|
global $wgImageLimits, $wgEnableUploads, $wgSend404Code;
|
2005-12-04 18:27:59 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2012-04-30 14:43:03 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
|
|
|
|
$user = $this->getContext()->getUser();
|
|
|
|
|
$lang = $this->getContext()->getLanguage();
|
|
|
|
|
$dirmark = $lang->getDirMarkEntity();
|
|
|
|
|
$request = $this->getContext()->getRequest();
|
2008-05-20 03:26:59 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$sizeSel = intval( $user->getOption( 'imagesize' ) );
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !isset( $wgImageLimits[$sizeSel] ) ) {
|
2004-12-21 03:21:41 +00:00
|
|
|
$sizeSel = User::getDefaultOption( 'imagesize' );
|
2007-02-02 16:22:22 +00:00
|
|
|
|
|
|
|
|
// The user offset might still be incorrect, specially if
|
|
|
|
|
// $wgImageLimits got changed (see bug #8858).
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !isset( $wgImageLimits[$sizeSel] ) ) {
|
2007-02-02 16:22:22 +00:00
|
|
|
// Default to the first offset in $wgImageLimits
|
|
|
|
|
$sizeSel = 0;
|
|
|
|
|
}
|
2004-09-10 00:53:31 +00:00
|
|
|
}
|
2004-12-21 03:21:41 +00:00
|
|
|
$max = $wgImageLimits[$sizeSel];
|
|
|
|
|
$maxWidth = $max[0];
|
|
|
|
|
$maxHeight = $max[1];
|
2004-01-12 00:55:01 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->displayImg->exists() ) {
|
2005-05-21 07:46:17 +00:00
|
|
|
# image
|
2012-04-30 14:43:03 +00:00
|
|
|
$page = $request->getIntOrNull( 'page' );
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( is_null( $page ) ) {
|
2007-04-20 12:31:36 +00:00
|
|
|
$params = array();
|
2006-08-13 17:34:48 +00:00
|
|
|
$page = 1;
|
2007-04-20 12:31:36 +00:00
|
|
|
} else {
|
|
|
|
|
$params = array( 'page' => $page );
|
2006-08-13 17:34:48 +00:00
|
|
|
}
|
2010-07-19 14:35:20 +00:00
|
|
|
$width_orig = $this->displayImg->getWidth( $page );
|
2007-02-27 18:27:11 +00:00
|
|
|
$width = $width_orig;
|
2010-07-19 14:35:20 +00:00
|
|
|
$height_orig = $this->displayImg->getHeight( $page );
|
2007-02-27 18:27:11 +00:00
|
|
|
$height = $height_orig;
|
2010-10-14 20:53:04 +00:00
|
|
|
|
2012-08-19 20:44:29 +00:00
|
|
|
$longDesc = wfMessage( 'parentheses', $this->displayImg->getLongDesc() )->text();
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$out ) );
|
2007-05-16 19:52:22 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->displayImg->allowInlineDisplay() ) {
|
2004-01-16 18:11:47 +00:00
|
|
|
# image
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2005-04-29 19:45:49 +00:00
|
|
|
# "Download high res version" link below the image
|
2012-08-19 20:44:29 +00:00
|
|
|
# $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
|
2005-12-04 08:52:01 +00:00
|
|
|
# We'll show a thumbnail of this image
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $width > $maxWidth || $height > $maxHeight ) {
|
2005-12-04 08:52:01 +00:00
|
|
|
# Calculate the thumbnail size.
|
|
|
|
|
# First case, the limiting factor is the width, not the height.
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $width / $height >= $maxWidth / $maxHeight ) {
|
|
|
|
|
$height = round( $height * $maxWidth / $width );
|
2005-12-04 08:52:01 +00:00
|
|
|
$width = $maxWidth;
|
|
|
|
|
# Note that $height <= $maxHeight now.
|
|
|
|
|
} else {
|
2010-03-20 22:58:48 +00:00
|
|
|
$newwidth = floor( $width * $maxHeight / $height );
|
2005-12-04 08:52:01 +00:00
|
|
|
$height = round( $height * $newwidth / $width );
|
|
|
|
|
$width = $newwidth;
|
|
|
|
|
# Note that $height <= $maxHeight now, but might not be identical
|
|
|
|
|
# because of rounding.
|
|
|
|
|
}
|
2012-08-19 20:44:29 +00:00
|
|
|
$msgbig = wfMessage( 'show-big-image' )->escaped();
|
2012-05-20 05:07:09 +00:00
|
|
|
if ( $this->displayImg->getRepo()->canTransformVia404() ) {
|
|
|
|
|
$thumbSizes = $wgImageLimits;
|
|
|
|
|
} else {
|
|
|
|
|
# Creating thumb links triggers thumbnail generation.
|
|
|
|
|
# Just generate the thumb for the current users prefs.
|
|
|
|
|
$thumbOption = $user->getOption( 'thumbsize' );
|
|
|
|
|
$thumbSizes = array( isset( $wgImageLimits[$thumbOption] )
|
|
|
|
|
? $wgImageLimits[$thumbOption]
|
|
|
|
|
: $wgImageLimits[User::getDefaultOption( 'thumbsize' )] );
|
|
|
|
|
}
|
|
|
|
|
# Generate thumbnails or thumbnail links as needed...
|
2011-03-12 22:49:31 +00:00
|
|
|
$otherSizes = array();
|
2012-05-20 05:07:09 +00:00
|
|
|
foreach ( $thumbSizes as $size ) {
|
|
|
|
|
if ( $size[0] < $width_orig && $size[1] < $height_orig
|
|
|
|
|
&& $size[0] != $width && $size[1] != $height )
|
|
|
|
|
{
|
2011-06-30 01:24:54 +00:00
|
|
|
$otherSizes[] = $this->makeSizeLink( $params, $size[0], $size[1] );
|
2011-10-15 21:40:30 +00:00
|
|
|
}
|
2011-03-12 22:49:31 +00:00
|
|
|
}
|
|
|
|
|
$msgsmall = wfMessage( 'show-big-image-preview' )->
|
|
|
|
|
rawParams( $this->makeSizeLink( $params, $width, $height ) )->
|
2012-01-27 22:44:46 +00:00
|
|
|
parse();
|
2012-05-20 05:07:09 +00:00
|
|
|
if ( count( $otherSizes ) ) {
|
2012-01-27 22:44:46 +00:00
|
|
|
$msgsmall .= ' ' .
|
2011-09-12 12:46:20 +00:00
|
|
|
Html::rawElement( 'span', array( 'class' => 'mw-filepage-other-resolutions' ),
|
2012-04-30 14:43:03 +00:00
|
|
|
wfMessage( 'show-big-image-other' )->rawParams( $lang->pipeList( $otherSizes ) )->
|
2011-11-11 16:09:34 +00:00
|
|
|
params( count( $otherSizes ) )->parse()
|
2011-09-12 12:46:20 +00:00
|
|
|
);
|
2012-01-27 22:44:46 +00:00
|
|
|
}
|
2011-11-11 15:59:40 +00:00
|
|
|
} elseif ( $width == 0 && $height == 0 ){
|
|
|
|
|
# Some sort of audio file that doesn't have dimensions
|
|
|
|
|
# Don't output a no hi res message for such a file
|
|
|
|
|
$msgsmall = '';
|
2007-04-27 22:04:01 +00:00
|
|
|
} else {
|
|
|
|
|
# Image is small enough to show full size on image page
|
2011-09-12 12:46:20 +00:00
|
|
|
$msgsmall = wfMessage( 'file-nohires' )->parse();
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
2007-04-27 22:04:01 +00:00
|
|
|
|
2007-04-20 12:31:36 +00:00
|
|
|
$params['width'] = $width;
|
2011-03-12 22:49:31 +00:00
|
|
|
$params['height'] = $height;
|
2008-05-21 21:33:58 +00:00
|
|
|
$thumbnail = $this->displayImg->transform( $params );
|
2005-12-04 08:52:01 +00:00
|
|
|
|
2010-10-27 01:50:07 +00:00
|
|
|
$showLink = true;
|
2011-09-12 12:46:20 +00:00
|
|
|
$anchorclose = Html::rawElement( 'div', array( 'class' => 'mw-filepage-resolutioninfo' ), $msgsmall );
|
2006-08-13 17:34:48 +00:00
|
|
|
|
2009-12-04 11:33:50 +00:00
|
|
|
$isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $isMulti ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( '<table class="multipageimage"><tr><td>' );
|
2006-08-13 17:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $thumbnail ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$options = array(
|
2008-05-21 21:33:58 +00:00
|
|
|
'alt' => $this->displayImg->getTitle()->getPrefixedText(),
|
2011-10-15 21:40:30 +00:00
|
|
|
'file-link' => true,
|
2007-08-31 02:51:23 +00:00
|
|
|
);
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( '<div class="fullImageLink" id="file">' .
|
2007-08-31 02:51:23 +00:00
|
|
|
$thumbnail->toHtml( $options ) .
|
2009-03-28 16:41:00 +00:00
|
|
|
$anchorclose . "</div>\n" );
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
2006-08-13 17:34:48 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $isMulti ) {
|
2008-05-21 21:33:58 +00:00
|
|
|
$count = $this->displayImg->pageCount();
|
2007-01-26 12:00:04 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $page > 1 ) {
|
2012-08-19 20:44:29 +00:00
|
|
|
$label = $out->parse( wfMessage( 'imgmultipageprev' )->text(), false );
|
2012-07-11 07:18:07 +00:00
|
|
|
$link = Linker::linkKnown(
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->getTitle(),
|
2009-06-06 22:42:48 +00:00
|
|
|
$label,
|
|
|
|
|
array(),
|
2012-07-11 07:18:07 +00:00
|
|
|
array( 'page' => $page - 1 )
|
2009-06-06 22:42:48 +00:00
|
|
|
);
|
2011-07-06 14:45:19 +00:00
|
|
|
$thumb1 = Linker::makeThumbLinkObj( $this->getTitle(), $this->displayImg, $link, $label, 'none',
|
2007-04-20 12:31:36 +00:00
|
|
|
array( 'page' => $page - 1 ) );
|
2007-01-26 12:00:04 +00:00
|
|
|
} else {
|
|
|
|
|
$thumb1 = '';
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $page < $count ) {
|
2012-08-19 20:44:29 +00:00
|
|
|
$label = wfMessage( 'imgmultipagenext' )->text();
|
2012-07-11 07:18:07 +00:00
|
|
|
$link = Linker::linkKnown(
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->getTitle(),
|
2009-06-06 22:42:48 +00:00
|
|
|
$label,
|
|
|
|
|
array(),
|
2012-07-11 07:18:07 +00:00
|
|
|
array( 'page' => $page + 1 )
|
2009-06-06 22:42:48 +00:00
|
|
|
);
|
2011-07-06 14:45:19 +00:00
|
|
|
$thumb2 = Linker::makeThumbLinkObj( $this->getTitle(), $this->displayImg, $link, $label, 'none',
|
2007-04-20 12:31:36 +00:00
|
|
|
array( 'page' => $page + 1 ) );
|
2007-01-26 12:00:04 +00:00
|
|
|
} else {
|
|
|
|
|
$thumb2 = '';
|
2006-08-13 17:34:48 +00:00
|
|
|
}
|
2007-01-26 12:00:04 +00:00
|
|
|
|
2007-01-26 12:10:06 +00:00
|
|
|
global $wgScript;
|
2008-05-10 11:56:02 +00:00
|
|
|
|
|
|
|
|
$formParams = array(
|
|
|
|
|
'name' => 'pageselector',
|
|
|
|
|
'action' => $wgScript,
|
|
|
|
|
'onchange' => 'document.pageselector.submit();',
|
|
|
|
|
);
|
2011-10-29 01:53:28 +00:00
|
|
|
$options = array();
|
2010-03-20 22:58:48 +00:00
|
|
|
for ( $i = 1; $i <= $count; $i++ ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$options[] = Xml::option( $lang->formatNum( $i ), $i, $i == $page );
|
2007-01-26 12:00:04 +00:00
|
|
|
}
|
2008-05-10 11:56:02 +00:00
|
|
|
$select = Xml::tags( 'select',
|
|
|
|
|
array( 'id' => 'pageselector', 'name' => 'page' ),
|
|
|
|
|
implode( "\n", $options ) );
|
|
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML(
|
2008-05-10 11:56:02 +00:00
|
|
|
'</td><td><div class="multipageimagenavbox">' .
|
|
|
|
|
Xml::openElement( 'form', $formParams ) .
|
2011-04-02 14:50:31 +00:00
|
|
|
Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
|
2012-08-19 20:44:29 +00:00
|
|
|
wfMessage( 'imgmultigoto' )->rawParams( $select )->parse() .
|
|
|
|
|
Xml::submitButton( wfMessage( 'imgmultigo' )->text() ) .
|
2008-05-10 11:56:02 +00:00
|
|
|
Xml::closeElement( 'form' ) .
|
2011-11-20 18:57:59 +00:00
|
|
|
"<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
|
2008-05-10 11:56:02 +00:00
|
|
|
);
|
2006-08-13 17:34:48 +00:00
|
|
|
}
|
2004-01-16 18:11:47 +00:00
|
|
|
} else {
|
2010-03-20 22:58:48 +00:00
|
|
|
# if direct link is allowed but it's not a renderable image, show an icon.
|
|
|
|
|
if ( $this->displayImg->isSafeFile() ) {
|
|
|
|
|
$icon = $this->displayImg->iconThumb();
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( '<div class="fullImageLink" id="file">' .
|
2011-04-02 14:50:31 +00:00
|
|
|
$icon->toHtml( array( 'file-link' => true ) ) .
|
|
|
|
|
"</div>\n" );
|
2005-05-21 07:46:17 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-05-21 07:46:17 +00:00
|
|
|
$showLink = true;
|
2004-01-16 18:11:47 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $showLink ) {
|
2008-05-21 21:33:58 +00:00
|
|
|
$filename = wfEscapeWikiText( $this->displayImg->getName() );
|
2010-10-27 01:50:07 +00:00
|
|
|
$linktext = $filename;
|
2011-10-15 21:40:30 +00:00
|
|
|
if ( isset( $msgbig ) ) {
|
|
|
|
|
$linktext = wfEscapeWikiText( $msgbig );
|
2010-10-27 01:50:07 +00:00
|
|
|
}
|
|
|
|
|
$medialink = "[[Media:$filename|$linktext]]";
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->displayImg->isSafeFile() ) {
|
2012-08-19 20:44:29 +00:00
|
|
|
$warning = wfMessage( 'mediawarning' )->plain();
|
2012-03-29 19:17:06 +00:00
|
|
|
// 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
|
|
|
|
|
// this will get messy.
|
|
|
|
|
// The dirmark, however, must not be immediately adjacent
|
|
|
|
|
// to the filename, because it can get copied with it.
|
|
|
|
|
// See bug 25277.
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addWikiText( <<<EOT
|
2012-03-29 19:17:06 +00:00
|
|
|
<div class="fullMedia"><span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span></div>
|
2005-08-12 04:44:43 +00:00
|
|
|
<div class="mediaWarning">$warning</div>
|
2007-05-30 21:02:32 +00:00
|
|
|
EOT
|
2005-08-12 04:44:43 +00:00
|
|
|
);
|
2005-05-21 07:46:17 +00:00
|
|
|
} else {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addWikiText( <<<EOT
|
2012-03-29 19:17:06 +00:00
|
|
|
<div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
|
2005-08-12 04:44:43 +00:00
|
|
|
</div>
|
2007-05-30 21:02:32 +00:00
|
|
|
EOT
|
2009-05-25 13:53:48 +00:00
|
|
|
);
|
2005-05-21 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2012-08-19 01:19:53 +00:00
|
|
|
// 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
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->displayImg->isLocal() ) {
|
2005-07-03 04:40:07 +00:00
|
|
|
$this->printSharedImageText();
|
2004-10-21 05:04:14 +00:00
|
|
|
}
|
2005-04-17 08:30:15 +00:00
|
|
|
} else {
|
|
|
|
|
# Image does not exist
|
2012-03-02 01:02:41 +00:00
|
|
|
if ( !$this->getID() ) {
|
|
|
|
|
# No article exists either
|
|
|
|
|
# Show deletion log to be consistent with normal articles
|
|
|
|
|
LogEventsList::showLogExtract(
|
2012-04-30 14:43:03 +00:00
|
|
|
$out,
|
2012-03-02 01:02:41 +00:00
|
|
|
array( 'delete', 'move' ),
|
|
|
|
|
$this->getTitle()->getPrefixedText(),
|
|
|
|
|
'',
|
|
|
|
|
array( 'lim' => 10,
|
|
|
|
|
'conds' => array( "log_action != 'revision'" ),
|
|
|
|
|
'showIfEmpty' => false,
|
|
|
|
|
'msgKey' => array( 'moveddeleted-notice' )
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
if ( $wgEnableUploads && $user->isAllowed( 'upload' ) ) {
|
2009-05-24 20:45:31 +00:00
|
|
|
// Only show an upload link if the user can upload
|
2009-05-25 13:53:48 +00:00
|
|
|
$uploadTitle = SpecialPage::getTitleFor( 'Upload' );
|
2009-06-15 13:20:40 +00:00
|
|
|
$nofile = array(
|
2009-05-25 13:53:48 +00:00
|
|
|
'filepage-nofile-link',
|
2011-06-29 22:09:51 +00:00
|
|
|
$uploadTitle->getFullURL( array( 'wpDestFile' => $this->mPage->getFile()->getName() ) )
|
2009-05-25 13:53:48 +00:00
|
|
|
);
|
2011-04-02 14:50:31 +00:00
|
|
|
} else {
|
2009-06-15 13:20:40 +00:00
|
|
|
$nofile = 'filepage-nofile';
|
2009-05-24 20:45:31 +00:00
|
|
|
}
|
2011-01-16 00:43:56 +00:00
|
|
|
// Note, if there is an image description page, but
|
|
|
|
|
// no image, then this setRobotPolicy is overriden
|
|
|
|
|
// by Article::View().
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->setRobotPolicy( 'noindex,nofollow' );
|
|
|
|
|
$out->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
|
2011-12-09 04:31:10 +00:00
|
|
|
if ( !$this->getID() && $wgSend404Code ) {
|
2011-01-16 00:43:56 +00:00
|
|
|
// If there is no image, no shared image, and no description page,
|
|
|
|
|
// output a 404, to be consistent with articles.
|
2012-04-30 14:43:03 +00:00
|
|
|
$request->response()->header( 'HTTP/1.1 404 Not Found' );
|
2011-01-16 00:43:56 +00:00
|
|
|
}
|
2004-01-12 00:55:01 +00:00
|
|
|
}
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->setFileVersion( $this->displayImg );
|
2004-01-12 00:55:01 +00:00
|
|
|
}
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2011-03-12 22:49:31 +00:00
|
|
|
/**
|
2011-06-30 01:24:54 +00:00
|
|
|
* Creates an thumbnail of specified size and returns an HTML link to it
|
2011-10-29 01:53:28 +00:00
|
|
|
* @param $params array Scaler parameters
|
|
|
|
|
* @param $width int
|
|
|
|
|
* @param $height int
|
|
|
|
|
* @return string
|
2011-03-12 22:49:31 +00:00
|
|
|
*/
|
2011-10-15 21:40:30 +00:00
|
|
|
private function makeSizeLink( $params, $width, $height ) {
|
2011-03-12 22:49:31 +00:00
|
|
|
$params['width'] = $width;
|
|
|
|
|
$params['height'] = $height;
|
|
|
|
|
$thumbnail = $this->displayImg->transform( $params );
|
|
|
|
|
if ( $thumbnail && !$thumbnail->isError() ) {
|
|
|
|
|
return Html::rawElement( 'a', array(
|
|
|
|
|
'href' => $thumbnail->getUrl(),
|
|
|
|
|
'class' => 'mw-thumbnail-link'
|
2011-10-15 21:40:30 +00:00
|
|
|
), wfMessage( 'show-big-image-size' )->numParams(
|
2011-06-30 01:24:54 +00:00
|
|
|
$thumbnail->getWidth(), $thumbnail->getHeight()
|
2011-03-12 22:49:31 +00:00
|
|
|
)->parse() );
|
|
|
|
|
} else {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2008-02-19 16:29:28 +00:00
|
|
|
/**
|
|
|
|
|
* Show a notice that the file is from a shared repository
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function printSharedImageText() {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
|
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
$descUrl = $this->mPage->getFile()->getDescriptionUrl();
|
|
|
|
|
$descText = $this->mPage->getFile()->getDescriptionText();
|
2009-03-28 08:21:29 +00:00
|
|
|
|
2010-11-19 01:40:56 +00:00
|
|
|
/* Add canonical to head if there is no local page for this shared file */
|
2011-06-29 22:09:51 +00:00
|
|
|
if( $descUrl && $this->mPage->getID() == 0 ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addLink( array( 'rel' => 'canonical', 'href' => $descUrl ) );
|
2010-11-17 00:23:30 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-28 16:41:00 +00:00
|
|
|
$wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
|
2011-06-29 22:09:51 +00:00
|
|
|
$repo = $this->mPage->getFile()->getRepo()->getDisplayName();
|
2009-03-28 08:21:29 +00:00
|
|
|
|
2012-08-19 20:44:29 +00:00
|
|
|
if ( $descUrl && $descText && wfMessage( 'sharedupload-desc-here' )->plain() !== '-' ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) );
|
2012-08-19 20:44:29 +00:00
|
|
|
} elseif ( $descUrl && wfMessage( 'sharedupload-desc-there' )->plain() !== '-' ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) );
|
2009-03-28 08:21:29 +00:00
|
|
|
} else {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ );
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $descText ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
$this->mExtraDescription = $descText;
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getUploadUrl() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2006-10-30 06:25:31 +00:00
|
|
|
$uploadTitle = SpecialPage::getTitleFor( 'Upload' );
|
2011-04-02 14:50:31 +00:00
|
|
|
return $uploadTitle->getFullURL( array(
|
2011-06-29 22:09:51 +00:00
|
|
|
'wpDestFile' => $this->mPage->getFile()->getName(),
|
2009-05-25 13:53:48 +00:00
|
|
|
'wpForReUpload' => 1
|
|
|
|
|
) );
|
2005-04-17 08:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
/**
|
|
|
|
|
* Print out the various links at the bottom of the image page, e.g. reupload,
|
|
|
|
|
* external editing (and instructions link) etc.
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function uploadLinksBox() {
|
2012-04-30 14:43:03 +00:00
|
|
|
global $wgEnableUploads, $wgUseExternalEditor;
|
2009-05-24 20:45:31 +00:00
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
if ( !$wgEnableUploads ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-07-03 05:21:06 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( !$this->mPage->getFile()->isLocal() ) {
|
2005-07-03 05:21:06 +00:00
|
|
|
return;
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2005-07-03 05:21:06 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
2012-08-13 20:15:53 +00:00
|
|
|
$out->addHTML( "<ul>\n" );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
# "Upload a new version of this file" link
|
2012-08-13 20:15:53 +00:00
|
|
|
$canUpload = $this->getTitle()->userCan( 'upload', $this->getContext()->getUser() );
|
|
|
|
|
if ( $canUpload && UploadBase::userCanReUpload( $this->getContext()->getUser(), $this->mPage->getFile()->name ) ) {
|
2012-08-19 20:44:29 +00:00
|
|
|
$ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMessage( 'uploadnewversion-linktext' )->text() );
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( "<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" );
|
2012-08-13 20:15:53 +00:00
|
|
|
} else {
|
2012-08-22 18:54:38 +00:00
|
|
|
$out->addHTML( "<li id=\"mw-imagepage-upload-disallowed\">" . $this->getContext()->msg( 'upload-disallowed-here' )->escaped() . "</li>\n" );
|
2005-09-05 06:16:48 +00:00
|
|
|
}
|
2008-03-19 16:58:56 +00:00
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
# External editing link
|
2010-02-05 14:07:18 +00:00
|
|
|
if ( $wgUseExternalEditor ) {
|
2012-07-11 07:18:07 +00:00
|
|
|
$elink = Linker::linkKnown(
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->getTitle(),
|
2012-08-19 20:44:29 +00:00
|
|
|
wfMessage( 'edit-externally' )->escaped(),
|
2010-02-05 14:07:18 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'action' => 'edit',
|
|
|
|
|
'externaledit' => 'true',
|
|
|
|
|
'mode' => 'file'
|
2012-07-11 07:18:07 +00:00
|
|
|
)
|
2010-02-05 14:07:18 +00:00
|
|
|
);
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML(
|
2011-04-02 14:50:31 +00:00
|
|
|
'<li id="mw-imagepage-edit-external">' . $elink . ' <small>' .
|
2012-08-19 20:44:29 +00:00
|
|
|
wfMessage( 'edit-externally-help' )->parse() .
|
|
|
|
|
"</small></li>\n"
|
2011-04-02 14:50:31 +00:00
|
|
|
);
|
2010-02-05 14:07:18 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( "</ul>\n" );
|
2005-03-24 13:30:09 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
protected function closeShowImage() { } # For overloading
|
2004-01-12 00:55:01 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function imageHistory() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2012-04-30 14:43:03 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
2008-12-14 07:10:42 +00:00
|
|
|
$pager = new ImageHistoryPseudoPager( $this );
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( $pager->getBody() );
|
|
|
|
|
$out->preventClickjacking( $pager->getPreventClickjacking() );
|
2005-04-30 01:59:51 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->mPage->getFile()->resetHistory(); // free db resources
|
2007-07-07 03:04:20 +00:00
|
|
|
|
2005-04-30 02:37:16 +00:00
|
|
|
# Exist check because we don't want to show this on pages where an image
|
|
|
|
|
# doesn't exist along with the noimage message, that would suck. -ævar
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->mPage->getFile()->exists() ) {
|
2005-04-30 01:59:51 +00:00
|
|
|
$this->uploadLinksBox();
|
|
|
|
|
}
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @param $target
|
|
|
|
|
* @param $limit
|
|
|
|
|
* @return ResultWrapper
|
|
|
|
|
*/
|
2011-05-14 12:20:45 +00:00
|
|
|
protected function queryImageLinks( $target, $limit ) {
|
2008-05-05 22:14:55 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
|
2011-05-14 12:20:45 +00:00
|
|
|
return $dbr->select(
|
2008-05-09 11:31:00 +00:00
|
|
|
array( 'imagelinks', 'page' ),
|
2011-05-14 12:20:45 +00:00
|
|
|
array( 'page_namespace', 'page_title', 'page_is_redirect', 'il_to' ),
|
|
|
|
|
array( 'il_to' => $target, 'il_from = page_id' ),
|
2008-05-09 11:31:00 +00:00
|
|
|
__METHOD__,
|
2011-06-30 01:24:54 +00:00
|
|
|
array( 'LIMIT' => $limit + 1, 'ORDER BY' => 'il_from', )
|
|
|
|
|
);
|
2011-05-14 12:20:45 +00:00
|
|
|
}
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2011-05-14 12:20:45 +00:00
|
|
|
protected function imageLinks() {
|
|
|
|
|
$limit = 100;
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
2011-06-29 22:09:51 +00:00
|
|
|
$res = $this->queryImageLinks( $this->getTitle()->getDbKey(), $limit + 1);
|
2011-05-14 12:20:45 +00:00
|
|
|
$rows = array();
|
|
|
|
|
$redirects = array();
|
|
|
|
|
foreach ( $res as $row ) {
|
|
|
|
|
if ( $row->page_is_redirect ) {
|
|
|
|
|
$redirects[$row->page_title] = array();
|
|
|
|
|
}
|
|
|
|
|
$rows[] = $row;
|
|
|
|
|
}
|
|
|
|
|
$count = count( $rows );
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2011-05-14 12:20:45 +00:00
|
|
|
$hasMore = $count > $limit;
|
|
|
|
|
if ( !$hasMore && count( $redirects ) ) {
|
2011-06-30 01:24:54 +00:00
|
|
|
$res = $this->queryImageLinks( array_keys( $redirects ),
|
2011-05-14 12:20:45 +00:00
|
|
|
$limit - count( $rows ) + 1 );
|
|
|
|
|
foreach ( $res as $row ) {
|
|
|
|
|
$redirects[$row->il_to][] = $row;
|
|
|
|
|
$count++;
|
|
|
|
|
}
|
|
|
|
|
$hasMore = ( $res->numRows() + count( $rows ) ) > $limit;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $count == 0 ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->wrapWikiMsg(
|
2011-04-02 14:50:31 +00:00
|
|
|
Html::rawElement( 'div',
|
|
|
|
|
array( 'id' => 'mw-imagepage-nolinkstoimage' ), "\n$1\n" ),
|
|
|
|
|
'nolinkstoimage'
|
|
|
|
|
);
|
2008-05-05 22:14:55 +00:00
|
|
|
return;
|
2008-08-08 20:55:25 +00:00
|
|
|
}
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
|
2011-05-14 12:20:45 +00:00
|
|
|
if ( !$hasMore ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addWikiMsg( 'linkstoimage', $count );
|
2008-08-07 18:46:18 +00:00
|
|
|
} else {
|
|
|
|
|
// More links than the limit. Add a link to [[Special:Whatlinkshere]]
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addWikiMsg( 'linkstoimage-more',
|
|
|
|
|
$this->getContext()->getLanguage()->formatNum( $limit ),
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->getTitle()->getPrefixedDBkey()
|
2008-08-08 21:31:38 +00:00
|
|
|
);
|
2008-05-05 22:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML(
|
2011-04-02 14:50:31 +00:00
|
|
|
Html::openElement( 'ul',
|
|
|
|
|
array( 'class' => 'mw-imagepage-linkstoimage' ) ) . "\n"
|
|
|
|
|
);
|
2008-05-09 11:31:00 +00:00
|
|
|
$count = 0;
|
2010-06-29 13:38:55 +00:00
|
|
|
|
|
|
|
|
// Sort the list by namespace:title
|
2011-05-14 12:20:45 +00:00
|
|
|
usort( $rows, array( $this, 'compare' ) );
|
2010-06-29 13:38:55 +00:00
|
|
|
|
|
|
|
|
// Create links for every element
|
2011-05-14 12:20:45 +00:00
|
|
|
$currentCount = 0;
|
|
|
|
|
foreach( $rows as $element ) {
|
|
|
|
|
$currentCount++;
|
|
|
|
|
if ( $currentCount > $limit ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2011-07-06 14:45:19 +00:00
|
|
|
$link = Linker::linkKnown( Title::makeTitle( $element->page_namespace, $element->page_title ) );
|
2011-05-14 12:20:45 +00:00
|
|
|
if ( !isset( $redirects[$element->page_title] ) ) {
|
|
|
|
|
$liContents = $link;
|
|
|
|
|
} else {
|
|
|
|
|
$ul = "<ul class='mw-imagepage-redirectstofile'>\n";
|
|
|
|
|
foreach ( $redirects[$element->page_title] as $row ) {
|
|
|
|
|
$currentCount++;
|
|
|
|
|
if ( $currentCount > $limit ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2011-07-06 14:45:19 +00:00
|
|
|
$link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
|
2011-05-14 12:20:45 +00:00
|
|
|
$ul .= Html::rawElement(
|
|
|
|
|
'li',
|
2012-07-16 23:10:01 +00:00
|
|
|
array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
|
2011-05-14 12:20:45 +00:00
|
|
|
$link2
|
|
|
|
|
) . "\n";
|
|
|
|
|
}
|
|
|
|
|
$ul .= '</ul>';
|
2011-06-30 01:24:54 +00:00
|
|
|
$liContents = wfMessage( 'linkstoimage-redirect' )->rawParams(
|
2011-05-14 12:20:45 +00:00
|
|
|
$link, $ul )->parse();
|
|
|
|
|
}
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( Html::rawElement(
|
2011-04-02 14:50:31 +00:00
|
|
|
'li',
|
2012-07-16 23:10:01 +00:00
|
|
|
array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
|
2011-05-14 12:20:45 +00:00
|
|
|
$liContents
|
2011-04-02 14:50:31 +00:00
|
|
|
) . "\n"
|
2010-06-29 13:38:55 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
};
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( Html::closeElement( 'ul' ) . "\n" );
|
2008-05-09 11:31:00 +00:00
|
|
|
$res->free();
|
2008-06-11 12:07:58 +00:00
|
|
|
|
2008-05-09 11:31:00 +00:00
|
|
|
// Add a links to [[Special:Whatlinkshere]]
|
2010-06-29 13:38:55 +00:00
|
|
|
if ( $count > $limit ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addWikiMsg( 'morelinkstoimage', $this->getTitle()->getPrefixedDBkey() );
|
2010-06-29 13:38:55 +00:00
|
|
|
}
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( Html::closeElement( 'div' ) . "\n" );
|
2008-05-05 22:14:55 +00:00
|
|
|
}
|
2008-06-11 12:07:58 +00:00
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function imageDupes() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2012-04-30 14:43:03 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
2008-05-20 03:26:59 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
$dupes = $this->mPage->getDuplicates();
|
2011-03-05 17:01:33 +00:00
|
|
|
if ( count( $dupes ) == 0 ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-05-15 07:16:22 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
|
|
|
|
|
$out->addWikiMsg( 'duplicatesoffile',
|
|
|
|
|
$this->getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->getTitle()->getDBkey()
|
2008-08-08 21:31:38 +00:00
|
|
|
);
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
|
2008-05-15 07:16:22 +00:00
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @var $file File
|
|
|
|
|
*/
|
2008-05-14 15:11:48 +00:00
|
|
|
foreach ( $dupes as $file ) {
|
2009-02-17 22:27:10 +00:00
|
|
|
$fromSrc = '';
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $file->isLocal() ) {
|
2012-07-11 07:18:07 +00:00
|
|
|
$link = Linker::linkKnown( $file->getTitle() );
|
2009-06-06 22:42:48 +00:00
|
|
|
} else {
|
2011-07-06 14:45:19 +00:00
|
|
|
$link = Linker::makeExternalLink( $file->getDescriptionUrl(),
|
2008-05-14 17:29:38 +00:00
|
|
|
$file->getTitle()->getPrefixedText() );
|
2012-08-19 20:44:29 +00:00
|
|
|
$fromSrc = wfMessage( 'shared-repo-from', $file->getRepo()->getDisplayName() )->text();
|
2008-08-08 21:31:38 +00:00
|
|
|
}
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
|
2008-05-14 15:11:48 +00:00
|
|
|
}
|
2012-04-30 14:43:03 +00:00
|
|
|
$out->addHTML( "</ul></div>\n" );
|
2008-05-14 15:11:48 +00:00
|
|
|
}
|
2008-05-05 22:14:55 +00:00
|
|
|
|
2006-06-07 06:40:24 +00:00
|
|
|
/**
|
2007-08-17 20:53:17 +00:00
|
|
|
* Delete the file, or an earlier version of it
|
2006-06-07 06:40:24 +00:00
|
|
|
*/
|
2007-08-17 20:53:17 +00:00
|
|
|
public function delete() {
|
2011-11-15 18:08:34 +00:00
|
|
|
$file = $this->mPage->getFile();
|
|
|
|
|
if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
|
2007-08-17 20:53:17 +00:00
|
|
|
// Standard article deletion
|
2010-07-25 21:08:34 +00:00
|
|
|
parent::delete();
|
2007-08-17 20:53:17 +00:00
|
|
|
return;
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2011-11-15 18:08:34 +00:00
|
|
|
|
|
|
|
|
$deleter = new FileDeleteForm( $file );
|
2007-08-17 20:53:17 +00:00
|
|
|
$deleter->execute();
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
/**
|
2007-07-22 14:45:12 +00:00
|
|
|
* Display an error with a wikitext description
|
2011-09-11 21:07:17 +00:00
|
|
|
*
|
|
|
|
|
* @param $description String
|
2007-05-30 21:02:32 +00:00
|
|
|
*/
|
2007-07-22 14:45:12 +00:00
|
|
|
function showError( $description ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
|
|
|
|
$out->setPageTitle( wfMessage( 'internalerror' ) );
|
|
|
|
|
$out->setRobotPolicy( 'noindex,nofollow' );
|
|
|
|
|
$out->setArticleRelated( false );
|
|
|
|
|
$out->enableClientCache( false );
|
|
|
|
|
$out->addWikiText( $description );
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-29 13:38:55 +00:00
|
|
|
/**
|
|
|
|
|
* Callback for usort() to do link sorts by (namespace, title)
|
|
|
|
|
* Function copied from Title::compare()
|
2011-06-30 01:24:54 +00:00
|
|
|
*
|
2010-06-29 13:38:55 +00:00
|
|
|
* @param $a object page to compare with
|
|
|
|
|
* @param $b object page to compare with
|
|
|
|
|
* @return Integer: result of string comparison, or namespace comparison
|
|
|
|
|
*/
|
|
|
|
|
protected function compare( $a, $b ) {
|
|
|
|
|
if ( $a->page_namespace == $b->page_namespace ) {
|
|
|
|
|
return strcmp( $a->page_title, $b->page_title );
|
|
|
|
|
} else {
|
|
|
|
|
return $a->page_namespace - $b->page_namespace;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2005-01-27 19:51:47 +00:00
|
|
|
/**
|
2007-07-29 18:41:49 +00:00
|
|
|
* Builds the image revision log shown on image pages
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Media
|
2005-01-27 19:51:47 +00:00
|
|
|
*/
|
2012-04-30 14:43:03 +00:00
|
|
|
class ImageHistoryList extends ContextSource {
|
2007-07-29 18:41:49 +00:00
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
|
|
|
|
protected $title;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var File
|
|
|
|
|
*/
|
|
|
|
|
protected $img;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var ImagePage
|
|
|
|
|
*/
|
|
|
|
|
protected $imagePage;
|
|
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @var File
|
|
|
|
|
*/
|
|
|
|
|
protected $current;
|
|
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
protected $repo, $showThumb;
|
2011-01-04 06:12:33 +00:00
|
|
|
protected $preventClickjacking = false;
|
2008-05-23 09:03:49 +00:00
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
|
|
|
|
* @param ImagePage $imagePage
|
|
|
|
|
*/
|
2008-05-23 09:03:49 +00:00
|
|
|
public function __construct( $imagePage ) {
|
2011-07-06 14:45:19 +00:00
|
|
|
global $wgShowArchiveThumbnails;
|
2008-05-23 09:03:49 +00:00
|
|
|
$this->current = $imagePage->getFile();
|
|
|
|
|
$this->img = $imagePage->getDisplayedFile();
|
|
|
|
|
$this->title = $imagePage->getTitle();
|
|
|
|
|
$this->imagePage = $imagePage;
|
2009-09-25 14:48:44 +00:00
|
|
|
$this->showThumb = $wgShowArchiveThumbnails && $this->img->canRender();
|
2012-04-30 14:43:03 +00:00
|
|
|
$this->setContext( $imagePage->getContext() );
|
2008-05-23 09:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @return ImagePage
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getImagePage() {
|
2008-05-23 09:03:49 +00:00
|
|
|
return $this->imagePage;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @return File
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getFile() {
|
2008-05-23 09:03:49 +00:00
|
|
|
return $this->img;
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @param $navLinks string
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2008-12-14 07:10:42 +00:00
|
|
|
public function beginImageHistoryList( $navLinks = '' ) {
|
2012-07-11 18:30:14 +00:00
|
|
|
return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) . "\n"
|
2009-03-28 16:41:00 +00:00
|
|
|
. "<div id=\"mw-imagepage-section-filehistory\">\n"
|
2012-07-11 18:30:14 +00:00
|
|
|
. $this->msg( 'filehist-help' )->parseAsBlock()
|
2009-03-28 16:41:00 +00:00
|
|
|
. $navLinks . "\n"
|
2009-06-17 18:05:03 +00:00
|
|
|
. Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
|
2008-05-19 15:21:29 +00:00
|
|
|
. '<tr><td></td>'
|
2012-04-30 14:43:03 +00:00
|
|
|
. ( $this->current->isLocal() && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' )
|
2012-07-11 18:30:14 +00:00
|
|
|
. '<th>' . $this->msg( 'filehist-datetime' )->escaped() . '</th>'
|
|
|
|
|
. ( $this->showThumb ? '<th>' . $this->msg( 'filehist-thumb' )->escaped() . '</th>' : '' )
|
|
|
|
|
. '<th>' . $this->msg( 'filehist-dimensions' )->escaped() . '</th>'
|
|
|
|
|
. '<th>' . $this->msg( 'filehist-user' )->escaped() . '</th>'
|
|
|
|
|
. '<th>' . $this->msg( 'filehist-comment' )->escaped() . '</th>'
|
2008-05-19 15:21:29 +00:00
|
|
|
. "</tr>\n";
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @param $navLinks string
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2008-12-14 07:10:42 +00:00
|
|
|
public function endImageHistoryList( $navLinks = '' ) {
|
2009-03-28 16:41:00 +00:00
|
|
|
return "</table>\n$navLinks\n</div>\n";
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
2011-04-02 14:50:31 +00:00
|
|
|
* @param $iscur
|
|
|
|
|
* @param $file File
|
2011-03-05 17:01:33 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2008-03-19 18:09:20 +00:00
|
|
|
public function imageHistoryLine( $iscur, $file ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
global $wgContLang;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2012-04-30 14:43:03 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
$lang = $this->getLanguage();
|
2010-03-20 22:58:48 +00:00
|
|
|
$timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
|
2008-03-19 18:09:20 +00:00
|
|
|
$img = $iscur ? $file->getName() : $file->getArchiveName();
|
2012-04-30 14:43:03 +00:00
|
|
|
$userId = $file->getUser( 'id' );
|
|
|
|
|
$userText = $file->getUser( 'text' );
|
2012-06-05 22:58:54 +00:00
|
|
|
$description = $file->getDescription( File::FOR_THIS_USER, $user );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-05-19 18:55:48 +00:00
|
|
|
$local = $this->current->isLocal();
|
2010-08-13 08:09:52 +00:00
|
|
|
$row = $selected = '';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
// Deletion link
|
2012-04-30 14:43:03 +00:00
|
|
|
if ( $local && ( $user->isAllowedAny( 'delete', 'deletedhistory' ) ) ) {
|
2008-05-19 15:21:29 +00:00
|
|
|
$row .= '<td>';
|
2008-03-19 18:09:20 +00:00
|
|
|
# Link to remove from history
|
2012-04-30 14:43:03 +00:00
|
|
|
if ( $user->isAllowed( 'delete' ) ) {
|
2009-04-07 16:37:29 +00:00
|
|
|
$q = array( 'action' => 'delete' );
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( !$iscur ) {
|
2009-04-07 16:37:29 +00:00
|
|
|
$q['oldimage'] = $img;
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2012-07-11 07:18:07 +00:00
|
|
|
$row .= Linker::linkKnown(
|
2008-03-19 18:09:20 +00:00
|
|
|
$this->title,
|
2012-07-11 18:30:14 +00:00
|
|
|
$this->msg( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' )->escaped(),
|
2012-07-11 07:18:07 +00:00
|
|
|
array(), $q
|
2008-03-19 18:09:20 +00:00
|
|
|
);
|
|
|
|
|
}
|
2009-09-28 03:09:48 +00:00
|
|
|
# Link to hide content. Don't show useless link to people who cannot hide revisions.
|
2012-04-30 14:43:03 +00:00
|
|
|
$canHide = $user->isAllowed( 'deleterevision' );
|
|
|
|
|
if ( $canHide || ( $user->isAllowed( 'deletedhistory' ) && $file->getVisibility() ) ) {
|
|
|
|
|
if ( $user->isAllowed( 'delete' ) ) {
|
2009-11-14 20:59:15 +00:00
|
|
|
$row .= '<br />';
|
2008-05-19 15:21:29 +00:00
|
|
|
}
|
2008-03-19 18:09:20 +00:00
|
|
|
// If file is top revision or locked from this user, don't link
|
2012-07-11 18:30:14 +00:00
|
|
|
if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED, $user ) ) {
|
2011-07-06 14:45:19 +00:00
|
|
|
$del = Linker::revDeleteLinkDisabled( $canHide );
|
2008-03-19 18:09:20 +00:00
|
|
|
} else {
|
2012-04-30 14:43:03 +00:00
|
|
|
list( $ts, ) = explode( '!', $img, 2 );
|
2009-10-29 05:58:53 +00:00
|
|
|
$query = array(
|
2009-10-30 02:14:22 +00:00
|
|
|
'type' => 'oldimage',
|
2010-06-03 19:28:13 +00:00
|
|
|
'target' => $this->title->getPrefixedText(),
|
2009-10-30 02:14:22 +00:00
|
|
|
'ids' => $ts,
|
2009-04-07 16:37:29 +00:00
|
|
|
);
|
2011-07-06 14:45:19 +00:00
|
|
|
$del = Linker::revDeleteLink( $query,
|
2010-03-20 22:58:48 +00:00
|
|
|
$file->isDeleted( File::DELETED_RESTRICTED ), $canHide );
|
2008-03-19 18:09:20 +00:00
|
|
|
}
|
2009-10-29 05:58:53 +00:00
|
|
|
$row .= $del;
|
2008-03-19 18:09:20 +00:00
|
|
|
}
|
2008-05-19 15:21:29 +00:00
|
|
|
$row .= '</td>';
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
// Reversion link/current indicator
|
2007-10-01 19:50:25 +00:00
|
|
|
$row .= '<td>';
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $iscur ) {
|
2012-07-11 18:30:14 +00:00
|
|
|
$row .= $this->msg( 'filehist-current' )->escaped();
|
|
|
|
|
} elseif ( $local && $this->title->quickUserCan( 'edit', $user )
|
|
|
|
|
&& $this->title->quickUserCan( 'upload', $user )
|
2012-06-05 22:58:54 +00:00
|
|
|
) {
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $file->isDeleted( File::DELETED_FILE ) ) {
|
2012-07-11 18:30:14 +00:00
|
|
|
$row .= $this->msg( 'filehist-revert' )->escaped();
|
2008-03-19 18:09:20 +00:00
|
|
|
} else {
|
2012-07-11 07:18:07 +00:00
|
|
|
$row .= Linker::linkKnown(
|
2009-06-06 22:42:48 +00:00
|
|
|
$this->title,
|
2012-07-11 18:30:14 +00:00
|
|
|
$this->msg( 'filehist-revert' )->escaped(),
|
2009-06-06 22:42:48 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'action' => 'revert',
|
|
|
|
|
'oldimage' => $img,
|
2012-04-30 14:43:03 +00:00
|
|
|
'wpEditToken' => $user->getEditToken( $img )
|
2012-07-11 07:18:07 +00:00
|
|
|
)
|
2009-06-06 22:42:48 +00:00
|
|
|
);
|
2008-03-19 18:09:20 +00:00
|
|
|
}
|
2007-07-29 18:41:49 +00:00
|
|
|
}
|
|
|
|
|
$row .= '</td>';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
// Date/time and image link
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $file->getTimestamp() === $this->img->getTimestamp() ) {
|
2008-05-19 18:55:48 +00:00
|
|
|
$selected = "class='filehistory-selected'";
|
|
|
|
|
}
|
|
|
|
|
$row .= "<td $selected style='white-space: nowrap;'>";
|
2012-07-11 18:30:14 +00:00
|
|
|
if ( !$file->userCan( File::DELETED_FILE, $user ) ) {
|
2008-03-19 18:09:20 +00:00
|
|
|
# Don't link to unviewable files
|
2012-07-11 18:30:14 +00:00
|
|
|
$row .= '<span class="history-deleted">' . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
|
2010-03-20 22:58:48 +00:00
|
|
|
} elseif ( $file->isDeleted( File::DELETED_FILE ) ) {
|
2011-04-06 18:45:27 +00:00
|
|
|
if ( $local ) {
|
|
|
|
|
$this->preventClickjacking();
|
|
|
|
|
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
|
|
|
|
|
# Make a link to review the image
|
2012-07-11 07:18:07 +00:00
|
|
|
$url = Linker::linkKnown(
|
2011-04-06 18:45:27 +00:00
|
|
|
$revdel,
|
2012-07-11 18:30:14 +00:00
|
|
|
$lang->userTimeAndDate( $timestamp, $user ),
|
2011-04-06 18:45:27 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'target' => $this->title->getPrefixedText(),
|
|
|
|
|
'file' => $img,
|
2012-04-30 14:43:03 +00:00
|
|
|
'token' => $user->getEditToken( $img )
|
2012-07-11 07:18:07 +00:00
|
|
|
)
|
2011-04-06 18:45:27 +00:00
|
|
|
);
|
|
|
|
|
} else {
|
2012-07-11 18:30:14 +00:00
|
|
|
$url = $lang->userTimeAndDate( $timestamp, $user );
|
2011-04-06 18:45:27 +00:00
|
|
|
}
|
2010-03-20 22:58:48 +00:00
|
|
|
$row .= '<span class="history-deleted">' . $url . '</span>';
|
2008-03-19 18:09:20 +00:00
|
|
|
} else {
|
2008-05-19 18:55:48 +00:00
|
|
|
$url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
|
2012-07-11 18:30:14 +00:00
|
|
|
$row .= Xml::element( 'a', array( 'href' => $url ), $lang->userTimeAndDate( $timestamp, $user ) );
|
2008-03-19 18:09:20 +00:00
|
|
|
}
|
2009-04-27 11:18:49 +00:00
|
|
|
$row .= "</td>";
|
2008-03-19 18:09:20 +00:00
|
|
|
|
2008-08-29 11:54:34 +00:00
|
|
|
// Thumbnail
|
2009-07-12 05:37:12 +00:00
|
|
|
if ( $this->showThumb ) {
|
|
|
|
|
$row .= '<td>' . $this->getThumbForLine( $file ) . '</td>';
|
|
|
|
|
}
|
2008-05-17 00:08:31 +00:00
|
|
|
|
2009-04-27 11:18:49 +00:00
|
|
|
// Image dimensions + size
|
|
|
|
|
$row .= '<td>';
|
|
|
|
|
$row .= htmlspecialchars( $file->getDimensionsString() );
|
2012-07-11 18:30:14 +00:00
|
|
|
$row .= $this->msg( 'word-separator' )->plain();
|
2012-06-05 22:58:54 +00:00
|
|
|
$row .= '<span style="white-space: nowrap;">';
|
2012-07-11 18:30:14 +00:00
|
|
|
$row .= $this->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain();
|
2012-06-05 22:58:54 +00:00
|
|
|
$row .= '</span>';
|
2009-04-27 11:18:49 +00:00
|
|
|
$row .= '</td>';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
// Uploading user
|
2009-04-27 11:18:49 +00:00
|
|
|
$row .= '<td>';
|
2011-04-06 18:23:07 +00:00
|
|
|
// Hide deleted usernames
|
|
|
|
|
if ( $file->isDeleted( File::DELETED_USER ) ) {
|
2012-07-11 18:30:14 +00:00
|
|
|
$row .= '<span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
|
2011-04-06 18:23:07 +00:00
|
|
|
} else {
|
|
|
|
|
if ( $local ) {
|
2012-05-29 08:28:07 +00:00
|
|
|
$row .= Linker::userLink( $userId, $userText );
|
2012-07-11 18:30:14 +00:00
|
|
|
$row .= $this->msg( 'word-separator' )->plain();
|
2012-05-29 08:28:07 +00:00
|
|
|
$row .= '<span style="white-space: nowrap;">';
|
|
|
|
|
$row .= Linker::userToolLinks( $userId, $userText );
|
|
|
|
|
$row .= '</span>';
|
2011-04-06 18:23:07 +00:00
|
|
|
} else {
|
2012-04-30 14:43:03 +00:00
|
|
|
$row .= htmlspecialchars( $userText );
|
2008-05-19 15:21:29 +00:00
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|
2011-07-11 00:39:41 +00:00
|
|
|
$row .= '</td>';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2008-03-19 18:09:20 +00:00
|
|
|
// Don't show deleted descriptions
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
|
2012-07-11 18:30:14 +00:00
|
|
|
$row .= '<td><span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span></td>';
|
2008-05-17 00:08:31 +00:00
|
|
|
} else {
|
2011-11-16 19:50:59 +00:00
|
|
|
$row .= '<td dir="' . $wgContLang->getDir() . '">' . Linker::formatComment( $description, $this->title ) . '</td>';
|
2008-05-17 00:08:31 +00:00
|
|
|
}
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2010-11-25 22:22:53 +00:00
|
|
|
$rowClass = null;
|
2008-05-23 09:03:49 +00:00
|
|
|
wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) );
|
2011-04-02 14:50:31 +00:00
|
|
|
$classAttr = $rowClass ? " class='$rowClass'" : '';
|
2008-05-19 18:55:48 +00:00
|
|
|
|
2008-05-23 09:03:49 +00:00
|
|
|
return "<tr{$classAttr}>{$row}</tr>\n";
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
2009-04-27 11:18:49 +00:00
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
2011-04-02 14:50:31 +00:00
|
|
|
* @param $file File
|
2011-03-05 17:01:33 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2009-04-27 11:18:49 +00:00
|
|
|
protected function getThumbForLine( $file ) {
|
2012-04-30 14:43:03 +00:00
|
|
|
$lang = $this->getLanguage();
|
2012-07-11 18:30:14 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE,$user )
|
|
|
|
|
&& !$file->isDeleted( File::DELETED_FILE ) )
|
|
|
|
|
{
|
2009-04-27 11:18:49 +00:00
|
|
|
$params = array(
|
|
|
|
|
'width' => '120',
|
|
|
|
|
'height' => '120',
|
|
|
|
|
);
|
2010-03-20 22:58:48 +00:00
|
|
|
$timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
|
2009-04-27 11:18:49 +00:00
|
|
|
|
|
|
|
|
$thumbnail = $file->transform( $params );
|
|
|
|
|
$options = array(
|
2012-07-11 18:30:14 +00:00
|
|
|
'alt' => $this->msg( 'filehist-thumbtext',
|
|
|
|
|
$lang->userTimeAndDate( $timestamp, $user ),
|
|
|
|
|
$lang->userDate( $timestamp, $user ),
|
|
|
|
|
$lang->userTime( $timestamp, $user ) )->text(),
|
2009-04-27 11:18:49 +00:00
|
|
|
'file-link' => true,
|
|
|
|
|
);
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( !$thumbnail ) {
|
2012-07-11 18:30:14 +00:00
|
|
|
return $this->msg( 'filehist-nothumb' )->escaped();
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2009-04-27 11:18:49 +00:00
|
|
|
|
|
|
|
|
return $thumbnail->toHtml( $options );
|
|
|
|
|
} else {
|
2012-07-11 18:30:14 +00:00
|
|
|
return $this->msg( 'filehist-nothumb' )->escaped();
|
2009-04-27 11:18:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-01-04 06:12:33 +00:00
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @param $enable bool
|
|
|
|
|
*/
|
2011-01-04 06:12:33 +00:00
|
|
|
protected function preventClickjacking( $enable = true ) {
|
|
|
|
|
$this->preventClickjacking = $enable;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2011-01-04 06:12:33 +00:00
|
|
|
public function getPreventClickjacking() {
|
|
|
|
|
return $this->preventClickjacking;
|
|
|
|
|
}
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
}
|
2008-12-14 07:10:42 +00:00
|
|
|
|
|
|
|
|
class ImageHistoryPseudoPager extends ReverseChronologicalPager {
|
2011-01-04 06:12:33 +00:00
|
|
|
protected $preventClickjacking = false;
|
|
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
|
|
|
|
* @var File
|
|
|
|
|
*/
|
|
|
|
|
protected $mImg;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
|
|
|
|
protected $mTitle;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param ImagePage $imagePage
|
|
|
|
|
*/
|
2008-12-14 07:10:42 +00:00
|
|
|
function __construct( $imagePage ) {
|
|
|
|
|
parent::__construct();
|
2008-12-23 17:58:22 +00:00
|
|
|
$this->mImagePage = $imagePage;
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mTitle = clone ( $imagePage->getTitle() );
|
2008-12-17 01:35:40 +00:00
|
|
|
$this->mTitle->setFragment( '#filehistory' );
|
2009-12-11 21:07:27 +00:00
|
|
|
$this->mImg = null;
|
2008-12-14 07:10:42 +00:00
|
|
|
$this->mHist = array();
|
|
|
|
|
$this->mRange = array( 0, 0 ); // display range
|
|
|
|
|
}
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @return Title
|
|
|
|
|
*/
|
2008-12-23 17:58:22 +00:00
|
|
|
function getTitle() {
|
|
|
|
|
return $this->mTitle;
|
|
|
|
|
}
|
2008-12-14 07:10:42 +00:00
|
|
|
|
|
|
|
|
function getQueryInfo() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2008-12-14 07:10:42 +00:00
|
|
|
function getIndexField() {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
2012-04-30 14:43:03 +00:00
|
|
|
* @param $row object
|
2011-10-29 01:53:28 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2008-12-14 07:10:42 +00:00
|
|
|
function formatRow( $row ) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2008-12-14 07:10:42 +00:00
|
|
|
function getBody() {
|
|
|
|
|
$s = '';
|
|
|
|
|
$this->doQuery();
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( count( $this->mHist ) ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
$list = new ImageHistoryList( $this->mImagePage );
|
|
|
|
|
# Generate prev/next links
|
2009-04-27 11:18:49 +00:00
|
|
|
$navLink = $this->getNavigationBar();
|
2010-03-20 22:58:48 +00:00
|
|
|
$s = $list->beginImageHistoryList( $navLink );
|
2008-12-14 07:10:42 +00:00
|
|
|
// Skip rows there just for paging links
|
2010-03-20 22:58:48 +00:00
|
|
|
for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
$file = $this->mHist[$i];
|
|
|
|
|
$s .= $list->imageHistoryLine( !$file->isOld(), $file );
|
|
|
|
|
}
|
2010-03-20 22:58:48 +00:00
|
|
|
$s .= $list->endImageHistoryList( $navLink );
|
2011-01-04 06:12:33 +00:00
|
|
|
|
|
|
|
|
if ( $list->getPreventClickjacking() ) {
|
|
|
|
|
$this->preventClickjacking();
|
|
|
|
|
}
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|
|
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function doQuery() {
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( $this->mQueryDone ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-12-14 07:10:42 +00:00
|
|
|
$this->mImg = $this->mImagePage->getFile(); // ensure loading
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->mImg->exists() ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$queryLimit = $this->mLimit + 1; // limit plus extra row
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->mIsBackwards ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
// Fetch the file history
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mHist = $this->mImg->getHistory( $queryLimit, null, $this->mOffset, false );
|
2008-12-14 07:10:42 +00:00
|
|
|
// The current rev may not meet the offset/limit
|
2010-03-20 22:58:48 +00:00
|
|
|
$numRows = count( $this->mHist );
|
|
|
|
|
if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) {
|
|
|
|
|
$this->mHist = array_merge( array( $this->mImg ), $this->mHist );
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// The current rev may not meet the offset
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->mOffset || $this->mImg->getTimestamp() < $this->mOffset ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
$this->mHist[] = $this->mImg;
|
|
|
|
|
}
|
|
|
|
|
// Old image versions (fetch extra row for nav links)
|
2010-03-20 22:58:48 +00:00
|
|
|
$oiLimit = count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
|
2008-12-14 07:10:42 +00:00
|
|
|
// Fetch the file history
|
|
|
|
|
$this->mHist = array_merge( $this->mHist,
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mImg->getHistory( $oiLimit, $this->mOffset, null, false ) );
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|
2010-03-20 22:58:48 +00:00
|
|
|
$numRows = count( $this->mHist ); // Total number of query results
|
|
|
|
|
if ( $numRows ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
# Index value of top item in the list
|
|
|
|
|
$firstIndex = $this->mIsBackwards ?
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp();
|
2008-12-14 07:10:42 +00:00
|
|
|
# Discard the extra result row if there is one
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $numRows > $this->mLimit && $numRows > 1 ) {
|
|
|
|
|
if ( $this->mIsBackwards ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
# Index value of item past the index
|
|
|
|
|
$this->mPastTheEndIndex = $this->mHist[0]->getTimestamp();
|
|
|
|
|
# Index value of bottom item in the list
|
|
|
|
|
$lastIndex = $this->mHist[1]->getTimestamp();
|
|
|
|
|
# Display range
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mRange = array( 1, $numRows - 1 );
|
2008-12-14 07:10:42 +00:00
|
|
|
} else {
|
|
|
|
|
# Index value of item past the index
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
|
2008-12-14 07:10:42 +00:00
|
|
|
# Index value of bottom item in the list
|
2010-03-20 22:58:48 +00:00
|
|
|
$lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
|
2008-12-14 07:10:42 +00:00
|
|
|
# Display range
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mRange = array( 0, $numRows - 2 );
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
# Setting indexes to an empty string means that they will be
|
|
|
|
|
# omitted if they would otherwise appear in URLs. It just so
|
|
|
|
|
# happens that this is the right thing to do in the standard
|
|
|
|
|
# UI, in all the relevant cases.
|
|
|
|
|
$this->mPastTheEndIndex = '';
|
|
|
|
|
# Index value of bottom item in the list
|
|
|
|
|
$lastIndex = $this->mIsBackwards ?
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
|
2008-12-14 07:10:42 +00:00
|
|
|
# Display range
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mRange = array( 0, $numRows - 1 );
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$firstIndex = '';
|
|
|
|
|
$lastIndex = '';
|
|
|
|
|
$this->mPastTheEndIndex = '';
|
|
|
|
|
}
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->mIsBackwards ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
$this->mIsFirst = ( $numRows < $queryLimit );
|
|
|
|
|
$this->mIsLast = ( $this->mOffset == '' );
|
|
|
|
|
$this->mLastShown = $firstIndex;
|
|
|
|
|
$this->mFirstShown = $lastIndex;
|
|
|
|
|
} else {
|
|
|
|
|
$this->mIsFirst = ( $this->mOffset == '' );
|
|
|
|
|
$this->mIsLast = ( $numRows < $queryLimit );
|
|
|
|
|
$this->mLastShown = $lastIndex;
|
|
|
|
|
$this->mFirstShown = $firstIndex;
|
|
|
|
|
}
|
|
|
|
|
$this->mQueryDone = true;
|
|
|
|
|
}
|
2011-06-30 01:24:54 +00:00
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @param $enable bool
|
|
|
|
|
*/
|
2011-01-04 06:12:33 +00:00
|
|
|
protected function preventClickjacking( $enable = true ) {
|
|
|
|
|
$this->preventClickjacking = $enable;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2011-01-04 06:12:33 +00:00
|
|
|
public function getPreventClickjacking() {
|
|
|
|
|
return $this->preventClickjacking;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|