2007-08-17 20:53:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* File deletion user interface
|
|
|
|
|
*
|
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
|
2007-08-17 20:53:17 +00:00
|
|
|
* @author Rob Church <robchur@gmail.com>
|
|
|
|
|
*/
|
|
|
|
|
class FileDeleteForm {
|
|
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
2007-08-17 20:53:17 +00:00
|
|
|
private $title = null;
|
2011-10-29 01:53:28 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var File
|
|
|
|
|
*/
|
2007-08-17 20:53:17 +00:00
|
|
|
private $file = null;
|
2007-08-20 14:49:07 +00:00
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
/**
|
|
|
|
|
* @var File
|
|
|
|
|
*/
|
2007-08-20 14:49:07 +00:00
|
|
|
private $oldfile = null;
|
2007-08-17 20:53:17 +00:00
|
|
|
private $oldimage = '';
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-10-29 01:53:28 +00:00
|
|
|
private $DeleteReason, $DeleteReasonList;
|
2007-08-17 20:53:17 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*
|
2010-01-13 21:25:03 +00:00
|
|
|
* @param $file File object we're deleting
|
2007-08-17 20:53:17 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct( $file ) {
|
|
|
|
|
$this->title = $file->getTitle();
|
|
|
|
|
$this->file = $file;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-17 20:53:17 +00:00
|
|
|
/**
|
|
|
|
|
* Fulfil the request; shows the form or deletes the file,
|
|
|
|
|
* pending authentication, confirmation, etc.
|
|
|
|
|
*/
|
|
|
|
|
public function execute() {
|
2007-08-21 03:57:54 +00:00
|
|
|
global $wgOut, $wgRequest, $wgUser;
|
2007-08-17 20:53:17 +00:00
|
|
|
|
2011-11-02 15:30:55 +00:00
|
|
|
$permissionErrors = $this->title->getUserPermissionsErrors( 'delete', $wgUser );
|
|
|
|
|
if ( count( $permissionErrors ) ) {
|
|
|
|
|
throw new PermissionsError( 'delete', $permissionErrors );
|
2007-08-17 20:53:17 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-09-23 16:15:30 +00:00
|
|
|
if ( wfReadOnly() ) {
|
|
|
|
|
throw new ReadOnlyError;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-02 15:30:55 +00:00
|
|
|
$this->setHeaders();
|
|
|
|
|
|
2007-10-01 19:50:25 +00:00
|
|
|
$this->oldimage = $wgRequest->getText( 'oldimage', false );
|
2007-08-17 20:53:17 +00:00
|
|
|
$token = $wgRequest->getText( 'wpEditToken' );
|
2008-03-15 00:27:57 +00:00
|
|
|
# Flag to hide all contents of the archived revisions
|
2008-05-25 00:31:28 +00:00
|
|
|
$suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed('suppressrevision');
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-09-23 16:15:30 +00:00
|
|
|
if( $this->oldimage ) {
|
2007-08-20 14:49:07 +00:00
|
|
|
$this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
|
2011-09-23 16:15:30 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-04 13:59:04 +00:00
|
|
|
if( !self::haveDeletableFile($this->file, $this->oldfile, $this->oldimage) ) {
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $this->prepareMessage( 'filedelete-nofile' ) );
|
2007-08-17 20:53:17 +00:00
|
|
|
$wgOut->addReturnTo( $this->title );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-17 20:53:17 +00:00
|
|
|
// Perform the deletion if appropriate
|
|
|
|
|
if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) {
|
2008-01-24 15:35:44 +00:00
|
|
|
$this->DeleteReasonList = $wgRequest->getText( 'wpDeleteReasonList' );
|
|
|
|
|
$this->DeleteReason = $wgRequest->getText( 'wpReason' );
|
|
|
|
|
$reason = $this->DeleteReasonList;
|
|
|
|
|
if ( $reason != 'other' && $this->DeleteReason != '') {
|
|
|
|
|
// Entry from drop down menu + additional comment
|
2009-01-07 22:49:54 +00:00
|
|
|
$reason .= wfMsgForContent( 'colon-separator' ) . $this->DeleteReason;
|
2008-01-24 15:35:44 +00:00
|
|
|
} elseif ( $reason == 'other' ) {
|
|
|
|
|
$reason = $this->DeleteReason;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-04 12:16:50 +00:00
|
|
|
$status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-08-19 23:30:12 +00:00
|
|
|
if( !$status->isGood() ) {
|
|
|
|
|
$wgOut->addHTML( '<h2>' . $this->prepareMessage( 'filedeleteerror-short' ) . "</h2>\n" );
|
|
|
|
|
$wgOut->addHTML( '<span class="error">' );
|
2007-08-17 20:53:17 +00:00
|
|
|
$wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) );
|
2011-08-19 23:30:12 +00:00
|
|
|
$wgOut->addHTML( '</span>' );
|
|
|
|
|
}
|
2007-08-17 20:53:17 +00:00
|
|
|
if( $status->ok ) {
|
2011-10-27 20:23:16 +00:00
|
|
|
$wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $this->prepareMessage( 'filedelete-success' ) );
|
2007-08-17 20:53:17 +00:00
|
|
|
// Return to the main page if we just deleted all versions of the
|
|
|
|
|
// file, otherwise go back to the description page
|
|
|
|
|
$wgOut->addReturnTo( $this->oldimage ? $this->title : Title::newMainPage() );
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-27 15:55:02 +00:00
|
|
|
$this->showForm();
|
|
|
|
|
$this->showLogEntries();
|
2007-08-17 20:53:17 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-01-13 21:25:03 +00:00
|
|
|
/**
|
|
|
|
|
* Really delete the file
|
|
|
|
|
*
|
|
|
|
|
* @param $title Title object
|
|
|
|
|
* @param $file File object
|
|
|
|
|
* @param $oldimage String: archive name
|
|
|
|
|
* @param $reason String: reason of the deletion
|
|
|
|
|
* @param $suppress Boolean: whether to mark all deleted versions as restricted
|
|
|
|
|
*/
|
2008-04-04 12:16:50 +00:00
|
|
|
public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress ) {
|
2009-11-27 17:46:35 +00:00
|
|
|
global $wgUser;
|
2008-04-04 12:16:50 +00:00
|
|
|
$article = null;
|
2010-02-26 20:14:28 +00:00
|
|
|
$status = Status::newFatal( 'error' );
|
|
|
|
|
|
2008-04-04 12:16:50 +00:00
|
|
|
if( $oldimage ) {
|
|
|
|
|
$status = $file->deleteOld( $oldimage, $reason, $suppress );
|
|
|
|
|
if( $status->ok ) {
|
|
|
|
|
// Need to do a log item
|
|
|
|
|
$log = new LogPage( 'delete' );
|
2009-11-02 17:12:37 +00:00
|
|
|
$logComment = wfMsgForContent( 'deletedrevision', $oldimage );
|
2010-08-29 19:11:23 +00:00
|
|
|
if( trim( $reason ) != '' ) {
|
2009-11-02 19:06:16 +00:00
|
|
|
$logComment .= wfMsgForContent( 'colon-separator' ) . $reason;
|
2010-08-29 19:11:23 +00:00
|
|
|
}
|
|
|
|
|
$log->addEntry( 'delete', $title, $logComment );
|
2008-04-04 12:16:50 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2010-09-30 19:13:25 +00:00
|
|
|
$id = $title->getArticleID( Title::GAID_FOR_UPDATE );
|
2010-02-26 20:14:28 +00:00
|
|
|
$article = new Article( $title );
|
|
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
|
|
|
|
try {
|
2011-03-23 21:54:59 +00:00
|
|
|
// delete the associated article first
|
|
|
|
|
if( $article->doDeleteArticle( $reason, $suppress, $id, false ) ) {
|
|
|
|
|
global $wgRequest;
|
WatchAction requires token (BREAKING CHANGE)
* (bug 27655) Require token for watching/unwatching pages
* Previously done for API (bug 29070) in r88522
* As with markpatrolled, the tokens are not compatible and made that way on purpose. The API requires the POST method and uses a universal token per-session. Since the front-end is all GET based (also per convention like in markpatrolled and rollback) they are stronger salted (title / action specific)
* ajax.watch used the API already and was switched in r88554.
* The actual watching/unwatching code was moved from WatchAction->onView to WatchAction::doWatch. This was done to allow the API to do the action without needing to generate a token like the front-end needs (or having to duplicate code). It is now similar to RecentChange::markPatrolled (in that it also a "central" function that does not care about tokens, it's called after the token-handling)
* JavaScript / Gadgets that utilize action=watch in their scripts:
** Effects should be minimal as they should be using the API (see r88522 and wikitech-l)
** If they use index.php and scrap the link from the page, they can continue to do so.
* There are links to the watch action all over the place. I've tried to catch most of them, but there may be some I miss. Migration in most cases is just a matter of adding an array item to the $query for:
'token' => WatchAction::getWatchToken( $title, $user [, $action] )
or changing:
Action::factory( 'watch', $article )->execute();
to:
WatchAction::doWatch( $title, $user );
While replacing the usages in some cases an instance of Article() no longer had to be created, in others $wgUser had to be retrieved from global (which was implied before but needs to be given directly now)
Other notes:
* Article->unwatch() and Article->watch(), which were deprecated as of 1.18 and are no longer used in core, may be broken in scenarios where the Request does not have a 'token' but is making a call to $article->watch()
* Some extensions need to be fixed, I'm currently running a grep search and will fix them a.s.a.p
[1] http://www.mediawiki.org/wiki/ResourceLoader/Default_modules?mw.user#tokens
2011-06-06 00:09:03 +00:00
|
|
|
if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
|
|
|
|
|
WatchAction::doWatch( $title, $wgUser );
|
|
|
|
|
} elseif ( $title->userIsWatching() ) {
|
|
|
|
|
WatchAction::doUnwatch( $title, $wgUser );
|
2011-03-23 21:54:59 +00:00
|
|
|
}
|
|
|
|
|
$status = $file->delete( $reason, $suppress );
|
|
|
|
|
if( $status->ok ) {
|
|
|
|
|
$dbw->commit();
|
|
|
|
|
} else {
|
|
|
|
|
$dbw->rollback();
|
2008-12-29 18:49:50 +00:00
|
|
|
}
|
2008-04-04 12:16:50 +00:00
|
|
|
}
|
2010-02-26 20:14:28 +00:00
|
|
|
} catch ( MWException $e ) {
|
|
|
|
|
// rollback before returning to prevent UI from displaying incorrect "View or restore N deleted edits?"
|
2010-02-26 20:18:48 +00:00
|
|
|
$dbw->rollback();
|
2010-02-26 20:14:28 +00:00
|
|
|
throw $e;
|
2008-04-04 12:16:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-08-19 23:30:12 +00:00
|
|
|
if( $status->isGood() )
|
2008-09-16 12:47:44 +00:00
|
|
|
wfRunHooks('FileDeleteComplete', array( &$file, &$oldimage, &$article, &$wgUser, &$reason));
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-04 12:16:50 +00:00
|
|
|
return $status;
|
|
|
|
|
}
|
2007-09-13 08:51:13 +00:00
|
|
|
|
2007-08-17 20:53:17 +00:00
|
|
|
/**
|
|
|
|
|
* Show the confirmation form
|
|
|
|
|
*/
|
|
|
|
|
private function showForm() {
|
2008-10-06 16:14:50 +00:00
|
|
|
global $wgOut, $wgUser, $wgRequest;
|
2007-09-13 08:51:13 +00:00
|
|
|
|
2008-05-25 00:31:28 +00:00
|
|
|
if( $wgUser->isAllowed( 'suppressrevision' ) ) {
|
2008-12-29 18:49:50 +00:00
|
|
|
$suppress = "<tr id=\"wpDeleteSuppressRow\">
|
2008-10-06 16:14:50 +00:00
|
|
|
<td></td>
|
2009-10-15 10:36:29 +00:00
|
|
|
<td class='mw-input'><strong>" .
|
2008-10-06 16:14:50 +00:00
|
|
|
Xml::checkLabel( wfMsg( 'revdelete-suppress' ),
|
|
|
|
|
'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '3' ) ) .
|
2009-10-15 10:36:29 +00:00
|
|
|
"</strong></td>
|
2008-10-06 16:14:50 +00:00
|
|
|
</tr>";
|
2008-03-15 00:27:57 +00:00
|
|
|
} else {
|
|
|
|
|
$suppress = '';
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-29 18:49:50 +00:00
|
|
|
$checkWatch = $wgUser->getBoolOption( 'watchdeletion' ) || $this->title->userIsWatching();
|
|
|
|
|
$form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction(),
|
|
|
|
|
'id' => 'mw-img-deleteconfirm' ) ) .
|
2008-01-29 06:10:12 +00:00
|
|
|
Xml::openElement( 'fieldset' ) .
|
2008-01-29 09:17:24 +00:00
|
|
|
Xml::element( 'legend', null, wfMsg( 'filedelete-legend' ) ) .
|
2010-10-31 16:20:48 +00:00
|
|
|
Html::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) ) .
|
2008-01-29 06:10:12 +00:00
|
|
|
$this->prepareMessage( 'filedelete-intro' ) .
|
2008-10-06 16:14:50 +00:00
|
|
|
Xml::openElement( 'table', array( 'id' => 'mw-img-deleteconfirm-table' ) ) .
|
2008-01-29 06:10:12 +00:00
|
|
|
"<tr>
|
2008-10-06 16:14:50 +00:00
|
|
|
<td class='mw-label'>" .
|
2008-01-29 06:10:12 +00:00
|
|
|
Xml::label( wfMsg( 'filedelete-comment' ), 'wpDeleteReasonList' ) .
|
|
|
|
|
"</td>
|
2008-10-06 16:14:50 +00:00
|
|
|
<td class='mw-input'>" .
|
2008-01-29 06:10:12 +00:00
|
|
|
Xml::listDropDown( 'wpDeleteReasonList',
|
2008-04-14 07:45:50 +00:00
|
|
|
wfMsgForContent( 'filedelete-reason-dropdown' ),
|
2008-01-29 06:10:12 +00:00
|
|
|
wfMsgForContent( 'filedelete-reason-otherlist' ), '', 'wpReasonDropDown', 1 ) .
|
|
|
|
|
"</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2008-10-06 16:14:50 +00:00
|
|
|
<td class='mw-label'>" .
|
2008-01-29 06:10:12 +00:00
|
|
|
Xml::label( wfMsg( 'filedelete-otherreason' ), 'wpReason' ) .
|
|
|
|
|
"</td>
|
2008-10-06 16:14:50 +00:00
|
|
|
<td class='mw-input'>" .
|
|
|
|
|
Xml::input( 'wpReason', 60, $wgRequest->getText( 'wpReason' ),
|
|
|
|
|
array( 'type' => 'text', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason' ) ) .
|
2008-01-29 06:10:12 +00:00
|
|
|
"</td>
|
|
|
|
|
</tr>
|
2009-11-14 11:07:46 +00:00
|
|
|
{$suppress}";
|
2011-08-19 23:30:12 +00:00
|
|
|
if( $wgUser->isLoggedIn() ) {
|
2009-11-14 11:07:46 +00:00
|
|
|
$form .= "
|
2008-12-29 18:49:50 +00:00
|
|
|
<tr>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td class='mw-input'>" .
|
|
|
|
|
Xml::checkLabel( wfMsg( 'watchthis' ),
|
|
|
|
|
'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) .
|
|
|
|
|
"</td>
|
2009-11-14 11:07:46 +00:00
|
|
|
</tr>";
|
|
|
|
|
}
|
|
|
|
|
$form .= "
|
2008-01-29 06:10:12 +00:00
|
|
|
<tr>
|
|
|
|
|
<td></td>
|
2008-10-06 16:14:50 +00:00
|
|
|
<td class='mw-submit'>" .
|
|
|
|
|
Xml::submitButton( wfMsg( 'filedelete-submit' ),
|
|
|
|
|
array( 'name' => 'mw-filedelete-submit', 'id' => 'mw-filedelete-submit', 'tabindex' => '4' ) ) .
|
2008-01-29 06:10:12 +00:00
|
|
|
"</td>
|
|
|
|
|
</tr>" .
|
|
|
|
|
Xml::closeElement( 'table' ) .
|
|
|
|
|
Xml::closeElement( 'fieldset' ) .
|
|
|
|
|
Xml::closeElement( 'form' );
|
2007-09-13 08:51:13 +00:00
|
|
|
|
2008-03-06 14:59:28 +00:00
|
|
|
if ( $wgUser->isAllowed( 'editinterface' ) ) {
|
2009-06-05 13:12:15 +00:00
|
|
|
$title = Title::makeTitle( NS_MEDIAWIKI, 'Filedelete-reason-dropdown' );
|
2011-09-23 16:15:30 +00:00
|
|
|
$link = Linker::link(
|
2009-05-27 20:35:16 +00:00
|
|
|
$title,
|
|
|
|
|
wfMsgHtml( 'filedelete-edit-reasonlist' ),
|
|
|
|
|
array(),
|
|
|
|
|
array( 'action' => 'edit' )
|
|
|
|
|
);
|
2008-03-06 14:59:28 +00:00
|
|
|
$form .= '<p class="mw-filedelete-editreasons">' . $link . '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $form );
|
2007-08-17 20:53:17 +00:00
|
|
|
}
|
2007-09-13 08:51:13 +00:00
|
|
|
|
2007-08-27 15:55:02 +00:00
|
|
|
/**
|
|
|
|
|
* Show deletion log fragments pertaining to the current file
|
|
|
|
|
*/
|
|
|
|
|
private function showLogEntries() {
|
|
|
|
|
global $wgOut;
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( '<h2>' . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
|
2011-09-24 17:52:53 +00:00
|
|
|
LogEventsList::showLogExtract( $wgOut, 'delete', $this->title );
|
2007-08-27 15:55:02 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-17 20:53:17 +00:00
|
|
|
/**
|
|
|
|
|
* Prepare a message referring to the file being deleted,
|
|
|
|
|
* showing an appropriate message depending upon whether
|
|
|
|
|
* it's a current file or an old version
|
|
|
|
|
*
|
2010-01-13 21:25:03 +00:00
|
|
|
* @param $message String: message base
|
|
|
|
|
* @return String
|
2007-08-17 20:53:17 +00:00
|
|
|
*/
|
|
|
|
|
private function prepareMessage( $message ) {
|
2008-02-13 05:59:14 +00:00
|
|
|
global $wgLang;
|
2007-08-17 20:53:17 +00:00
|
|
|
if( $this->oldimage ) {
|
|
|
|
|
return wfMsgExt(
|
2008-01-29 06:10:12 +00:00
|
|
|
"{$message}-old", # To ensure grep will find them: 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
|
2007-08-17 20:53:17 +00:00
|
|
|
'parse',
|
2011-06-22 14:59:05 +00:00
|
|
|
wfEscapeWikiText( $this->title->getText() ),
|
2007-08-20 14:35:59 +00:00
|
|
|
$wgLang->date( $this->getTimestamp(), true ),
|
|
|
|
|
$wgLang->time( $this->getTimestamp(), true ),
|
2011-08-19 15:46:08 +00:00
|
|
|
wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ), PROTO_CURRENT ) );
|
2007-08-17 20:53:17 +00:00
|
|
|
} else {
|
|
|
|
|
return wfMsgExt(
|
|
|
|
|
$message,
|
|
|
|
|
'parse',
|
2011-06-22 14:59:05 +00:00
|
|
|
wfEscapeWikiText( $this->title->getText() )
|
2007-08-17 20:53:17 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-17 20:53:17 +00:00
|
|
|
/**
|
|
|
|
|
* Set headers, titles and other bits
|
|
|
|
|
*/
|
|
|
|
|
private function setHeaders() {
|
2011-09-23 16:15:30 +00:00
|
|
|
global $wgOut;
|
2011-10-27 20:23:16 +00:00
|
|
|
$wgOut->setPageTitle( wfMessage( 'filedelete', $this->title->getText() ) );
|
2007-08-17 20:53:17 +00:00
|
|
|
$wgOut->setRobotPolicy( 'noindex,nofollow' );
|
2009-06-06 22:42:48 +00:00
|
|
|
$wgOut->setSubtitle( wfMsg(
|
|
|
|
|
'filedelete-backlink',
|
2011-09-23 16:15:30 +00:00
|
|
|
Linker::linkKnown( $this->title )
|
2009-06-06 22:42:48 +00:00
|
|
|
) );
|
2007-08-17 20:53:17 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-17 20:53:17 +00:00
|
|
|
/**
|
|
|
|
|
* Is the provided `oldimage` value valid?
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2008-04-04 13:59:04 +00:00
|
|
|
public static function isValidOldSpec($oldimage) {
|
|
|
|
|
return strlen( $oldimage ) >= 16
|
|
|
|
|
&& strpos( $oldimage, '/' ) === false
|
|
|
|
|
&& strpos( $oldimage, '\\' ) === false;
|
2007-08-17 20:53:17 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-17 20:53:17 +00:00
|
|
|
/**
|
|
|
|
|
* Could we delete the file specified? If an `oldimage`
|
|
|
|
|
* value was provided, does it correspond to an
|
|
|
|
|
* existing, local, old version of this file?
|
|
|
|
|
*
|
2011-10-29 01:53:28 +00:00
|
|
|
* @param $file File
|
|
|
|
|
* @param $oldfile File
|
|
|
|
|
* @param $oldimage File
|
2007-08-17 20:53:17 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2008-04-04 13:59:04 +00:00
|
|
|
public static function haveDeletableFile(&$file, &$oldfile, $oldimage) {
|
|
|
|
|
return $oldimage
|
|
|
|
|
? $oldfile && $oldfile->exists() && $oldfile->isLocal()
|
|
|
|
|
: $file && $file->exists() && $file->isLocal();
|
2007-08-17 20:53:17 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-17 20:53:17 +00:00
|
|
|
/**
|
|
|
|
|
* Prepare the form action
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
private function getAction() {
|
2009-06-07 10:34:02 +00:00
|
|
|
$q = array();
|
2009-06-06 22:42:48 +00:00
|
|
|
$q['action'] = 'delete';
|
2009-06-07 10:34:02 +00:00
|
|
|
|
2007-08-17 20:53:17 +00:00
|
|
|
if( $this->oldimage )
|
2009-06-06 22:42:48 +00:00
|
|
|
$q['oldimage'] = $this->oldimage;
|
2009-06-07 10:34:02 +00:00
|
|
|
|
2009-06-06 22:42:48 +00:00
|
|
|
return $this->title->getLocalUrl( $q );
|
2007-08-17 20:53:17 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-17 20:53:17 +00:00
|
|
|
/**
|
|
|
|
|
* Extract the timestamp of the old version
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
private function getTimestamp() {
|
2007-08-20 14:49:07 +00:00
|
|
|
return $this->oldfile->getTimestamp();
|
2007-08-17 20:53:17 +00:00
|
|
|
}
|
2008-01-25 10:15:46 +00:00
|
|
|
}
|