* split time and date in 'emailauthenticated', and 'undelete-revision', retaiming...
[lhc/web/wiklou.git] / includes / specials / SpecialUndelete.php
1 <?php
2
3 /**
4 * Special page allowing users with the appropriate permissions to view
5 * and restore deleted content
6 *
7 * @file
8 * @ingroup SpecialPage
9 */
10
11 /**
12 * Constructor
13 */
14 function wfSpecialUndelete( $par ) {
15 global $wgRequest;
16
17 $form = new UndeleteForm( $wgRequest, $par );
18 $form->execute();
19 }
20
21 /**
22 * Used to show archived pages and eventually restore them.
23 * @ingroup SpecialPage
24 */
25 class PageArchive {
26 protected $title;
27 var $fileStatus;
28
29 function __construct( $title ) {
30 if( is_null( $title ) ) {
31 throw new MWException( 'Archiver() given a null title.');
32 }
33 $this->title = $title;
34 }
35
36 /**
37 * List all deleted pages recorded in the archive table. Returns result
38 * wrapper with (ar_namespace, ar_title, count) fields, ordered by page
39 * namespace/title.
40 *
41 * @return ResultWrapper
42 */
43 public static function listAllPages() {
44 $dbr = wfGetDB( DB_SLAVE );
45 return self::listPages( $dbr, '' );
46 }
47
48 /**
49 * List deleted pages recorded in the archive table matching the
50 * given title prefix.
51 * Returns result wrapper with (ar_namespace, ar_title, count) fields.
52 *
53 * @return ResultWrapper
54 */
55 public static function listPagesByPrefix( $prefix ) {
56 $dbr = wfGetDB( DB_SLAVE );
57
58 $title = Title::newFromText( $prefix );
59 if( $title ) {
60 $ns = $title->getNamespace();
61 $encPrefix = $dbr->escapeLike( $title->getDBkey() );
62 } else {
63 // Prolly won't work too good
64 // @todo handle bare namespace names cleanly?
65 $ns = 0;
66 $encPrefix = $dbr->escapeLike( $prefix );
67 }
68 $conds = array(
69 'ar_namespace' => $ns,
70 "ar_title LIKE '$encPrefix%'",
71 );
72 return self::listPages( $dbr, $conds );
73 }
74
75 protected static function listPages( $dbr, $condition ) {
76 return $dbr->resultObject(
77 $dbr->select(
78 array( 'archive' ),
79 array(
80 'ar_namespace',
81 'ar_title',
82 'COUNT(*) AS count'
83 ),
84 $condition,
85 __METHOD__,
86 array(
87 'GROUP BY' => 'ar_namespace,ar_title',
88 'ORDER BY' => 'ar_namespace,ar_title',
89 'LIMIT' => 100,
90 )
91 )
92 );
93 }
94
95 /**
96 * List the revisions of the given page. Returns result wrapper with
97 * (ar_minor_edit, ar_timestamp, ar_user, ar_user_text, ar_comment) fields.
98 *
99 * @return ResultWrapper
100 */
101 function listRevisions() {
102 $dbr = wfGetDB( DB_SLAVE );
103 $res = $dbr->select( 'archive',
104 array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len', 'ar_deleted' ),
105 array( 'ar_namespace' => $this->title->getNamespace(),
106 'ar_title' => $this->title->getDBkey() ),
107 'PageArchive::listRevisions',
108 array( 'ORDER BY' => 'ar_timestamp DESC' ) );
109 $ret = $dbr->resultObject( $res );
110 return $ret;
111 }
112
113 /**
114 * List the deleted file revisions for this page, if it's a file page.
115 * Returns a result wrapper with various filearchive fields, or null
116 * if not a file page.
117 *
118 * @return ResultWrapper
119 * @todo Does this belong in Image for fuller encapsulation?
120 */
121 function listFiles() {
122 if( $this->title->getNamespace() == NS_IMAGE ) {
123 $dbr = wfGetDB( DB_SLAVE );
124 $res = $dbr->select( 'filearchive',
125 array(
126 'fa_id',
127 'fa_name',
128 'fa_archive_name',
129 'fa_storage_key',
130 'fa_storage_group',
131 'fa_size',
132 'fa_width',
133 'fa_height',
134 'fa_bits',
135 'fa_metadata',
136 'fa_media_type',
137 'fa_major_mime',
138 'fa_minor_mime',
139 'fa_description',
140 'fa_user',
141 'fa_user_text',
142 'fa_timestamp',
143 'fa_deleted' ),
144 array( 'fa_name' => $this->title->getDBkey() ),
145 __METHOD__,
146 array( 'ORDER BY' => 'fa_timestamp DESC' ) );
147 $ret = $dbr->resultObject( $res );
148 return $ret;
149 }
150 return null;
151 }
152
153 /**
154 * Fetch (and decompress if necessary) the stored text for the deleted
155 * revision of the page with the given timestamp.
156 *
157 * @return string
158 * @deprecated Use getRevision() for more flexible information
159 */
160 function getRevisionText( $timestamp ) {
161 $rev = $this->getRevision( $timestamp );
162 return $rev ? $rev->getText() : null;
163 }
164
165 /**
166 * Return a Revision object containing data for the deleted revision.
167 * Note that the result *may* or *may not* have a null page ID.
168 * @param string $timestamp
169 * @return Revision
170 */
171 function getRevision( $timestamp ) {
172 $dbr = wfGetDB( DB_SLAVE );
173 $row = $dbr->selectRow( 'archive',
174 array(
175 'ar_rev_id',
176 'ar_text',
177 'ar_comment',
178 'ar_user',
179 'ar_user_text',
180 'ar_timestamp',
181 'ar_minor_edit',
182 'ar_flags',
183 'ar_text_id',
184 'ar_deleted',
185 'ar_len' ),
186 array( 'ar_namespace' => $this->title->getNamespace(),
187 'ar_title' => $this->title->getDBkey(),
188 'ar_timestamp' => $dbr->timestamp( $timestamp ) ),
189 __METHOD__ );
190 if( $row ) {
191 return new Revision( array(
192 'page' => $this->title->getArticleId(),
193 'id' => $row->ar_rev_id,
194 'text' => ($row->ar_text_id
195 ? null
196 : Revision::getRevisionText( $row, 'ar_' ) ),
197 'comment' => $row->ar_comment,
198 'user' => $row->ar_user,
199 'user_text' => $row->ar_user_text,
200 'timestamp' => $row->ar_timestamp,
201 'minor_edit' => $row->ar_minor_edit,
202 'text_id' => $row->ar_text_id,
203 'deleted' => $row->ar_deleted,
204 'len' => $row->ar_len) );
205 } else {
206 return null;
207 }
208 }
209
210 /**
211 * Return the most-previous revision, either live or deleted, against
212 * the deleted revision given by timestamp.
213 *
214 * May produce unexpected results in case of history merges or other
215 * unusual time issues.
216 *
217 * @param string $timestamp
218 * @return Revision or null
219 */
220 function getPreviousRevision( $timestamp ) {
221 $dbr = wfGetDB( DB_SLAVE );
222
223 // Check the previous deleted revision...
224 $row = $dbr->selectRow( 'archive',
225 'ar_timestamp',
226 array( 'ar_namespace' => $this->title->getNamespace(),
227 'ar_title' => $this->title->getDBkey(),
228 'ar_timestamp < ' .
229 $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ),
230 __METHOD__,
231 array(
232 'ORDER BY' => 'ar_timestamp DESC',
233 'LIMIT' => 1 ) );
234 $prevDeleted = $row ? wfTimestamp( TS_MW, $row->ar_timestamp ) : false;
235
236 $row = $dbr->selectRow( array( 'page', 'revision' ),
237 array( 'rev_id', 'rev_timestamp' ),
238 array(
239 'page_namespace' => $this->title->getNamespace(),
240 'page_title' => $this->title->getDBkey(),
241 'page_id = rev_page',
242 'rev_timestamp < ' .
243 $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ),
244 __METHOD__,
245 array(
246 'ORDER BY' => 'rev_timestamp DESC',
247 'LIMIT' => 1 ) );
248 $prevLive = $row ? wfTimestamp( TS_MW, $row->rev_timestamp ) : false;
249 $prevLiveId = $row ? intval( $row->rev_id ) : null;
250
251 if( $prevLive && $prevLive > $prevDeleted ) {
252 // Most prior revision was live
253 return Revision::newFromId( $prevLiveId );
254 } elseif( $prevDeleted ) {
255 // Most prior revision was deleted
256 return $this->getRevision( $prevDeleted );
257 } else {
258 // No prior revision on this page.
259 return null;
260 }
261 }
262
263 /**
264 * Get the text from an archive row containing ar_text, ar_flags and ar_text_id
265 */
266 function getTextFromRow( $row ) {
267 if( is_null( $row->ar_text_id ) ) {
268 // An old row from MediaWiki 1.4 or previous.
269 // Text is embedded in this row in classic compression format.
270 return Revision::getRevisionText( $row, "ar_" );
271 } else {
272 // New-style: keyed to the text storage backend.
273 $dbr = wfGetDB( DB_SLAVE );
274 $text = $dbr->selectRow( 'text',
275 array( 'old_text', 'old_flags' ),
276 array( 'old_id' => $row->ar_text_id ),
277 __METHOD__ );
278 return Revision::getRevisionText( $text );
279 }
280 }
281
282
283 /**
284 * Fetch (and decompress if necessary) the stored text of the most
285 * recently edited deleted revision of the page.
286 *
287 * If there are no archived revisions for the page, returns NULL.
288 *
289 * @return string
290 */
291 function getLastRevisionText() {
292 $dbr = wfGetDB( DB_SLAVE );
293 $row = $dbr->selectRow( 'archive',
294 array( 'ar_text', 'ar_flags', 'ar_text_id' ),
295 array( 'ar_namespace' => $this->title->getNamespace(),
296 'ar_title' => $this->title->getDBkey() ),
297 'PageArchive::getLastRevisionText',
298 array( 'ORDER BY' => 'ar_timestamp DESC' ) );
299 if( $row ) {
300 return $this->getTextFromRow( $row );
301 } else {
302 return NULL;
303 }
304 }
305
306 /**
307 * Quick check if any archived revisions are present for the page.
308 * @return bool
309 */
310 function isDeleted() {
311 $dbr = wfGetDB( DB_SLAVE );
312 $n = $dbr->selectField( 'archive', 'COUNT(ar_title)',
313 array( 'ar_namespace' => $this->title->getNamespace(),
314 'ar_title' => $this->title->getDBkey() ) );
315 return ($n > 0);
316 }
317
318 /**
319 * Restore the given (or all) text and file revisions for the page.
320 * Once restored, the items will be removed from the archive tables.
321 * The deletion log will be updated with an undeletion notice.
322 *
323 * @param array $timestamps Pass an empty array to restore all revisions, otherwise list the ones to undelete.
324 * @param string $comment
325 * @param array $fileVersions
326 * @param bool $unsuppress
327 *
328 * @return array(number of file revisions restored, number of image revisions restored, log message)
329 * on success, false on failure
330 */
331 function undelete( $timestamps, $comment = '', $fileVersions = array(), $unsuppress = false ) {
332 // If both the set of text revisions and file revisions are empty,
333 // restore everything. Otherwise, just restore the requested items.
334 $restoreAll = empty( $timestamps ) && empty( $fileVersions );
335
336 $restoreText = $restoreAll || !empty( $timestamps );
337 $restoreFiles = $restoreAll || !empty( $fileVersions );
338
339 if( $restoreFiles && $this->title->getNamespace() == NS_IMAGE ) {
340 $img = wfLocalFile( $this->title );
341 $this->fileStatus = $img->restore( $fileVersions, $unsuppress );
342 $filesRestored = $this->fileStatus->successCount;
343 } else {
344 $filesRestored = 0;
345 }
346
347 if( $restoreText ) {
348 $textRestored = $this->undeleteRevisions( $timestamps, $unsuppress );
349 if($textRestored === false) // It must be one of UNDELETE_*
350 return false;
351 } else {
352 $textRestored = 0;
353 }
354
355 // Touch the log!
356 global $wgContLang;
357 $log = new LogPage( 'delete' );
358
359 if( $textRestored && $filesRestored ) {
360 $reason = wfMsgExt( 'undeletedrevisions-files', array( 'content', 'parsemag' ),
361 $wgContLang->formatNum( $textRestored ),
362 $wgContLang->formatNum( $filesRestored ) );
363 } elseif( $textRestored ) {
364 $reason = wfMsgExt( 'undeletedrevisions', array( 'content', 'parsemag' ),
365 $wgContLang->formatNum( $textRestored ) );
366 } elseif( $filesRestored ) {
367 $reason = wfMsgExt( 'undeletedfiles', array( 'content', 'parsemag' ),
368 $wgContLang->formatNum( $filesRestored ) );
369 } else {
370 wfDebug( "Undelete: nothing undeleted...\n" );
371 return false;
372 }
373
374 if( trim( $comment ) != '' )
375 $reason .= ": {$comment}";
376 $log->addEntry( 'restore', $this->title, $reason );
377
378 return array($textRestored, $filesRestored, $reason);
379 }
380
381 /**
382 * This is the meaty bit -- restores archived revisions of the given page
383 * to the cur/old tables. If the page currently exists, all revisions will
384 * be stuffed into old, otherwise the most recent will go into cur.
385 *
386 * @param array $timestamps Pass an empty array to restore all revisions, otherwise list the ones to undelete.
387 * @param string $comment
388 * @param array $fileVersions
389 * @param bool $unsuppress, remove all ar_deleted/fa_deleted restrictions of seletected revs
390 *
391 * @return mixed number of revisions restored or false on failure
392 */
393 private function undeleteRevisions( $timestamps, $unsuppress = false ) {
394 if ( wfReadOnly() )
395 return false;
396 $restoreAll = empty( $timestamps );
397
398 $dbw = wfGetDB( DB_MASTER );
399
400 # Does this page already exist? We'll have to update it...
401 $article = new Article( $this->title );
402 $options = 'FOR UPDATE';
403 $page = $dbw->selectRow( 'page',
404 array( 'page_id', 'page_latest' ),
405 array( 'page_namespace' => $this->title->getNamespace(),
406 'page_title' => $this->title->getDBkey() ),
407 __METHOD__,
408 $options );
409 if( $page ) {
410 $makepage = false;
411 # Page already exists. Import the history, and if necessary
412 # we'll update the latest revision field in the record.
413 $newid = 0;
414 $pageId = $page->page_id;
415 $previousRevId = $page->page_latest;
416 # Get the time span of this page
417 $previousTimestamp = $dbw->selectField( 'revision', 'rev_timestamp',
418 array( 'rev_id' => $previousRevId ),
419 __METHOD__ );
420 if( $previousTimestamp === false ) {
421 wfDebug( __METHOD__.": existing page refers to a page_latest that does not exist\n" );
422 return 0;
423 }
424 } else {
425 # Have to create a new article...
426 $makepage = true;
427 $previousRevId = 0;
428 $previousTimestamp = 0;
429 }
430
431 if( $restoreAll ) {
432 $oldones = '1 = 1'; # All revisions...
433 } else {
434 $oldts = implode( ',',
435 array_map( array( &$dbw, 'addQuotes' ),
436 array_map( array( &$dbw, 'timestamp' ),
437 $timestamps ) ) );
438
439 $oldones = "ar_timestamp IN ( {$oldts} )";
440 }
441
442 /**
443 * Select each archived revision...
444 */
445 $result = $dbw->select( 'archive',
446 /* fields */ array(
447 'ar_rev_id',
448 'ar_text',
449 'ar_comment',
450 'ar_user',
451 'ar_user_text',
452 'ar_timestamp',
453 'ar_minor_edit',
454 'ar_flags',
455 'ar_text_id',
456 'ar_deleted',
457 'ar_page_id',
458 'ar_len' ),
459 /* WHERE */ array(
460 'ar_namespace' => $this->title->getNamespace(),
461 'ar_title' => $this->title->getDBkey(),
462 $oldones ),
463 __METHOD__,
464 /* options */ array(
465 'ORDER BY' => 'ar_timestamp' )
466 );
467 $ret = $dbw->resultObject( $result );
468
469 $rev_count = $dbw->numRows( $result );
470 if( $rev_count ) {
471 # We need to seek around as just using DESC in the ORDER BY
472 # would leave the revisions inserted in the wrong order
473 $first = $ret->fetchObject();
474 $ret->seek( $rev_count - 1 );
475 $last = $ret->fetchObject();
476 // We don't handle well changing the top revision's settings
477 if( !$unsuppress && $last->ar_deleted && $last->ar_timestamp > $previousTimestamp ) {
478 wfDebug( __METHOD__.": restoration would result in a deleted top revision\n" );
479 return false;
480 }
481 $ret->seek( 0 );
482 }
483
484 if( $makepage ) {
485 $newid = $article->insertOn( $dbw );
486 $pageId = $newid;
487 }
488
489 $revision = null;
490 $restored = 0;
491
492 while( $row = $ret->fetchObject() ) {
493 if( $row->ar_text_id ) {
494 // Revision was deleted in 1.5+; text is in
495 // the regular text table, use the reference.
496 // Specify null here so the so the text is
497 // dereferenced for page length info if needed.
498 $revText = null;
499 } else {
500 // Revision was deleted in 1.4 or earlier.
501 // Text is squashed into the archive row, and
502 // a new text table entry will be created for it.
503 $revText = Revision::getRevisionText( $row, 'ar_' );
504 }
505 $revision = new Revision( array(
506 'page' => $pageId,
507 'id' => $row->ar_rev_id,
508 'text' => $revText,
509 'comment' => $row->ar_comment,
510 'user' => $row->ar_user,
511 'user_text' => $row->ar_user_text,
512 'timestamp' => $row->ar_timestamp,
513 'minor_edit' => $row->ar_minor_edit,
514 'text_id' => $row->ar_text_id,
515 'deleted' => $unsuppress ? 0 : $row->ar_deleted,
516 'len' => $row->ar_len
517 ) );
518 $revision->insertOn( $dbw );
519 $restored++;
520
521 wfRunHooks( 'ArticleRevisionUndeleted', array( &$this->title, $revision, $row->ar_page_id ) );
522 }
523 // Was anything restored at all?
524 if($restored == 0)
525 return 0;
526
527 if( $revision ) {
528 // Attach the latest revision to the page...
529 $wasnew = $article->updateIfNewerOn( $dbw, $revision, $previousRevId );
530
531 if( $newid || $wasnew ) {
532 // Update site stats, link tables, etc
533 $article->createUpdates( $revision );
534 }
535
536 if( $newid ) {
537 wfRunHooks( 'ArticleUndelete', array( &$this->title, true ) );
538 Article::onArticleCreate( $this->title );
539 } else {
540 wfRunHooks( 'ArticleUndelete', array( &$this->title, false ) );
541 Article::onArticleEdit( $this->title );
542 }
543
544 if( $this->title->getNamespace() == NS_IMAGE ) {
545 $update = new HTMLCacheUpdate( $this->title, 'imagelinks' );
546 $update->doUpdate();
547 }
548 } else {
549 // Revision couldn't be created. This is very weird
550 return self::UNDELETE_UNKNOWNERR;
551 }
552
553 # Now that it's safely stored, take it out of the archive
554 $dbw->delete( 'archive',
555 /* WHERE */ array(
556 'ar_namespace' => $this->title->getNamespace(),
557 'ar_title' => $this->title->getDBkey(),
558 $oldones ),
559 __METHOD__ );
560
561 return $restored;
562 }
563
564 function getFileStatus() { return $this->fileStatus; }
565 }
566
567 /**
568 * The HTML form for Special:Undelete, which allows users with the appropriate
569 * permissions to view and restore deleted content.
570 * @ingroup SpecialPage
571 */
572 class UndeleteForm {
573 var $mAction, $mTarget, $mTimestamp, $mRestore, $mTargetObj;
574 var $mTargetTimestamp, $mAllowed, $mComment;
575
576 function UndeleteForm( $request, $par = "" ) {
577 global $wgUser;
578 $this->mAction = $request->getVal( 'action' );
579 $this->mTarget = $request->getVal( 'target' );
580 $this->mSearchPrefix = $request->getText( 'prefix' );
581 $time = $request->getVal( 'timestamp' );
582 $this->mTimestamp = $time ? wfTimestamp( TS_MW, $time ) : '';
583 $this->mFile = $request->getVal( 'file' );
584
585 $posted = $request->wasPosted() &&
586 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
587 $this->mRestore = $request->getCheck( 'restore' ) && $posted;
588 $this->mPreview = $request->getCheck( 'preview' ) && $posted;
589 $this->mDiff = $request->getCheck( 'diff' );
590 $this->mComment = $request->getText( 'wpComment' );
591 $this->mUnsuppress = $request->getVal( 'wpUnsuppress' ) && $wgUser->isAllowed( 'suppressrevision' );
592
593 if( $par != "" ) {
594 $this->mTarget = $par;
595 }
596 if ( $wgUser->isAllowed( 'undelete' ) && !$wgUser->isBlocked() ) {
597 $this->mAllowed = true;
598 } else {
599 $this->mAllowed = false;
600 $this->mTimestamp = '';
601 $this->mRestore = false;
602 }
603 if ( $this->mTarget !== "" ) {
604 $this->mTargetObj = Title::newFromURL( $this->mTarget );
605 } else {
606 $this->mTargetObj = NULL;
607 }
608 if( $this->mRestore ) {
609 $timestamps = array();
610 $this->mFileVersions = array();
611 foreach( $_REQUEST as $key => $val ) {
612 $matches = array();
613 if( preg_match( '/^ts(\d{14})$/', $key, $matches ) ) {
614 array_push( $timestamps, $matches[1] );
615 }
616
617 if( preg_match( '/^fileid(\d+)$/', $key, $matches ) ) {
618 $this->mFileVersions[] = intval( $matches[1] );
619 }
620 }
621 rsort( $timestamps );
622 $this->mTargetTimestamp = $timestamps;
623 }
624 }
625
626 function execute() {
627 global $wgOut, $wgUser;
628 if ( $this->mAllowed ) {
629 $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
630 } else {
631 $wgOut->setPagetitle( wfMsg( "viewdeletedpage" ) );
632 }
633
634 if( is_null( $this->mTargetObj ) ) {
635 # Not all users can just browse every deleted page from the list
636 if( $wgUser->isAllowed( 'browsearchive' ) ) {
637 $this->showSearchForm();
638
639 # List undeletable articles
640 if( $this->mSearchPrefix ) {
641 $result = PageArchive::listPagesByPrefix( $this->mSearchPrefix );
642 $this->showList( $result );
643 }
644 } else {
645 $wgOut->addWikiText( wfMsgHtml( 'undelete-header' ) );
646 }
647 return;
648 }
649 if( $this->mTimestamp !== '' ) {
650 return $this->showRevision( $this->mTimestamp );
651 }
652 if( $this->mFile !== null ) {
653 $file = new ArchivedFile( $this->mTargetObj, '', $this->mFile );
654 // Check if user is allowed to see this file
655 if( !$file->userCan( File::DELETED_FILE ) ) {
656 $wgOut->permissionRequired( 'suppressrevision' );
657 return false;
658 } else {
659 return $this->showFile( $this->mFile );
660 }
661 }
662 if( $this->mRestore && $this->mAction == "submit" ) {
663 return $this->undelete();
664 }
665 return $this->showHistory();
666 }
667
668 function showSearchForm() {
669 global $wgOut, $wgScript;
670 $wgOut->addWikiMsg( 'undelete-header' );
671
672 $wgOut->addHtml(
673 Xml::openElement( 'form', array(
674 'method' => 'get',
675 'action' => $wgScript ) ) .
676 '<fieldset>' .
677 Xml::element( 'legend', array(),
678 wfMsg( 'undelete-search-box' ) ) .
679 Xml::hidden( 'title',
680 SpecialPage::getTitleFor( 'Undelete' )->getPrefixedDbKey() ) .
681 Xml::inputLabel( wfMsg( 'undelete-search-prefix' ),
682 'prefix', 'prefix', 20,
683 $this->mSearchPrefix ) .
684 Xml::submitButton( wfMsg( 'undelete-search-submit' ) ) .
685 '</fieldset>' .
686 '</form>' );
687 }
688
689 // Generic list of deleted pages
690 private function showList( $result ) {
691 global $wgLang, $wgContLang, $wgUser, $wgOut;
692
693 if( $result->numRows() == 0 ) {
694 $wgOut->addWikiMsg( 'undelete-no-results' );
695 return;
696 }
697
698 $wgOut->addWikiMsg( "undeletepagetext" );
699
700 $sk = $wgUser->getSkin();
701 $undelete = SpecialPage::getTitleFor( 'Undelete' );
702 $wgOut->addHTML( "<ul>\n" );
703 while( $row = $result->fetchObject() ) {
704 $title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
705 $link = $sk->makeKnownLinkObj( $undelete, htmlspecialchars( $title->getPrefixedText() ),
706 'target=' . $title->getPrefixedUrl() );
707 #$revs = wfMsgHtml( 'undeleterevisions', $wgLang->formatNum( $row->count ) );
708 $revs = wfMsgExt( 'undeleterevisions',
709 array( 'parseinline' ),
710 $wgLang->formatNum( $row->count ) );
711 $wgOut->addHtml( "<li>{$link} ({$revs})</li>\n" );
712 }
713 $result->free();
714 $wgOut->addHTML( "</ul>\n" );
715
716 return true;
717 }
718
719 private function showRevision( $timestamp ) {
720 global $wgLang, $wgUser, $wgOut;
721 $self = SpecialPage::getTitleFor( 'Undelete' );
722 $skin = $wgUser->getSkin();
723
724 if(!preg_match("/[0-9]{14}/",$timestamp)) return 0;
725
726 $archive = new PageArchive( $this->mTargetObj );
727 $rev = $archive->getRevision( $timestamp );
728
729 if( !$rev ) {
730 $wgOut->addWikiMsg( 'undeleterevision-missing' );
731 return;
732 }
733
734 if( $rev->isDeleted(Revision::DELETED_TEXT) ) {
735 if( !$rev->userCan(Revision::DELETED_TEXT) ) {
736 $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) );
737 return;
738 } else {
739 $wgOut->addWikiText( wfMsg( 'rev-deleted-text-view' ) );
740 $wgOut->addHTML( '<br/>' );
741 // and we are allowed to see...
742 }
743 }
744
745 $wgOut->setPageTitle( wfMsg( 'undeletepage' ) );
746
747 $link = $skin->makeKnownLinkObj(
748 SpecialPage::getTitleFor( 'Undelete', $this->mTargetObj->getPrefixedDBkey() ),
749 htmlspecialchars( $this->mTargetObj->getPrefixedText() )
750 );
751
752 if( $this->mDiff ) {
753 $previousRev = $archive->getPreviousRevision( $timestamp );
754 if( $previousRev ) {
755 $this->showDiff( $previousRev, $rev );
756 if( $wgUser->getOption( 'diffonly' ) ) {
757 return;
758 } else {
759 $wgOut->addHtml( '<hr />' );
760 }
761 } else {
762 $wgOut->addHtml( wfMsgHtml( 'undelete-nodiff' ) );
763 }
764 }
765
766 // date and time are separate parameters to facilitate localisation.
767 // $time is kept for backward compat reasons.
768 $time = htmlspecialchars( $wgLang->timeAndDate( $timestamp, true ) );
769 $d = htmlspecialchars( $wgLang->date( $timestamp, true ) );
770 $t = htmlspecialchars( $wgLang->time( $timestamp, true ) );
771 $user = $skin->revUserTools( $rev );
772
773 $wgOut->addHtml( '<p>' . wfMsgHtml( 'undelete-revision', $link, $time, $user, $t, $d ) . '</p>' );
774
775 wfRunHooks( 'UndeleteShowRevision', array( $this->mTargetObj, $rev ) );
776
777 if( $this->mPreview ) {
778 $wgOut->addHtml( "<hr />\n" );
779
780 //Hide [edit]s
781 $popts = $wgOut->parserOptions();
782 $popts->setEditSection( false );
783 $wgOut->parserOptions( $popts );
784 $wgOut->addWikiTextTitleTidy( $rev->revText(), $this->mTargetObj, true );
785 }
786
787 $wgOut->addHtml(
788 wfElement( 'textarea', array(
789 'readonly' => 'readonly',
790 'cols' => intval( $wgUser->getOption( 'cols' ) ),
791 'rows' => intval( $wgUser->getOption( 'rows' ) ) ),
792 $rev->revText() . "\n" ) .
793 wfOpenElement( 'div' ) .
794 wfOpenElement( 'form', array(
795 'method' => 'post',
796 'action' => $self->getLocalURL( "action=submit" ) ) ) .
797 wfElement( 'input', array(
798 'type' => 'hidden',
799 'name' => 'target',
800 'value' => $this->mTargetObj->getPrefixedDbKey() ) ) .
801 wfElement( 'input', array(
802 'type' => 'hidden',
803 'name' => 'timestamp',
804 'value' => $timestamp ) ) .
805 wfElement( 'input', array(
806 'type' => 'hidden',
807 'name' => 'wpEditToken',
808 'value' => $wgUser->editToken() ) ) .
809 wfElement( 'input', array(
810 'type' => 'submit',
811 'name' => 'preview',
812 'value' => wfMsg( 'showpreview' ) ) ) .
813 wfElement( 'input', array(
814 'name' => 'diff',
815 'type' => 'submit',
816 'value' => wfMsg( 'showdiff' ) ) ) .
817 wfCloseElement( 'form' ) .
818 wfCloseElement( 'div' ) );
819 }
820
821 /**
822 * Build a diff display between this and the previous either deleted
823 * or non-deleted edit.
824 * @param Revision $previousRev
825 * @param Revision $currentRev
826 * @return string HTML
827 */
828 function showDiff( $previousRev, $currentRev ) {
829 global $wgOut, $wgUser;
830
831 $diffEngine = new DifferenceEngine();
832 $diffEngine->showDiffStyle();
833 $wgOut->addHtml(
834 "<div>" .
835 "<table border='0' width='98%' cellpadding='0' cellspacing='4' class='diff'>" .
836 "<col class='diff-marker' />" .
837 "<col class='diff-content' />" .
838 "<col class='diff-marker' />" .
839 "<col class='diff-content' />" .
840 "<tr>" .
841 "<td colspan='2' width='50%' align='center' class='diff-otitle'>" .
842 $this->diffHeader( $previousRev ) .
843 "</td>" .
844 "<td colspan='2' width='50%' align='center' class='diff-ntitle'>" .
845 $this->diffHeader( $currentRev ) .
846 "</td>" .
847 "</tr>" .
848 $diffEngine->generateDiffBody(
849 $previousRev->getText(), $currentRev->getText() ) .
850 "</table>" .
851 "</div>\n" );
852
853 }
854
855 private function diffHeader( $rev ) {
856 global $wgUser, $wgLang, $wgLang;
857 $sk = $wgUser->getSkin();
858 $isDeleted = !( $rev->getId() && $rev->getTitle() );
859 if( $isDeleted ) {
860 /// @fixme $rev->getTitle() is null for deleted revs...?
861 $targetPage = SpecialPage::getTitleFor( 'Undelete' );
862 $targetQuery = 'target=' .
863 $this->mTargetObj->getPrefixedUrl() .
864 '&timestamp=' .
865 wfTimestamp( TS_MW, $rev->getTimestamp() );
866 } else {
867 /// @fixme getId() may return non-zero for deleted revs...
868 $targetPage = $rev->getTitle();
869 $targetQuery = 'oldid=' . $rev->getId();
870 }
871 return
872 '<div id="mw-diff-otitle1"><strong>' .
873 $sk->makeLinkObj( $targetPage,
874 wfMsgHtml( 'revisionasof',
875 $wgLang->timeanddate( $rev->getTimestamp(), true ) ),
876 $targetQuery ) .
877 ( $isDeleted ? ' ' . wfMsgHtml( 'deletedrev' ) : '' ) .
878 '</strong></div>' .
879 '<div id="mw-diff-otitle2">' .
880 $sk->revUserTools( $rev ) . '<br/>' .
881 '</div>' .
882 '<div id="mw-diff-otitle3">' .
883 $sk->revComment( $rev ) . '<br/>' .
884 '</div>';
885 }
886
887 /**
888 * Show a deleted file version requested by the visitor.
889 */
890 private function showFile( $key ) {
891 global $wgOut, $wgRequest;
892 $wgOut->disable();
893
894 # We mustn't allow the output to be Squid cached, otherwise
895 # if an admin previews a deleted image, and it's cached, then
896 # a user without appropriate permissions can toddle off and
897 # nab the image, and Squid will serve it
898 $wgRequest->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
899 $wgRequest->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
900 $wgRequest->response()->header( 'Pragma: no-cache' );
901
902 $store = FileStore::get( 'deleted' );
903 $store->stream( $key );
904 }
905
906 private function showHistory() {
907 global $wgLang, $wgUser, $wgOut;
908
909 $sk = $wgUser->getSkin();
910 if( $this->mAllowed ) {
911 $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
912 } else {
913 $wgOut->setPagetitle( wfMsg( 'viewdeletedpage' ) );
914 }
915
916 $wgOut->addWikiText( wfMsgHtml( 'undeletepagetitle', $this->mTargetObj->getPrefixedText()) );
917
918 $archive = new PageArchive( $this->mTargetObj );
919 /*
920 $text = $archive->getLastRevisionText();
921 if( is_null( $text ) ) {
922 $wgOut->addWikiMsg( "nohistory" );
923 return;
924 }
925 */
926 if ( $this->mAllowed ) {
927 $wgOut->addWikiMsg( "undeletehistory" );
928 $wgOut->addWikiMsg( "undeleterevdel" );
929 } else {
930 $wgOut->addWikiMsg( "undeletehistorynoadmin" );
931 }
932
933 # List all stored revisions
934 $revisions = $archive->listRevisions();
935 $files = $archive->listFiles();
936
937 $haveRevisions = $revisions && $revisions->numRows() > 0;
938 $haveFiles = $files && $files->numRows() > 0;
939
940 # Batch existence check on user and talk pages
941 if( $haveRevisions ) {
942 $batch = new LinkBatch();
943 while( $row = $revisions->fetchObject() ) {
944 $batch->addObj( Title::makeTitleSafe( NS_USER, $row->ar_user_text ) );
945 $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->ar_user_text ) );
946 }
947 $batch->execute();
948 $revisions->seek( 0 );
949 }
950 if( $haveFiles ) {
951 $batch = new LinkBatch();
952 while( $row = $files->fetchObject() ) {
953 $batch->addObj( Title::makeTitleSafe( NS_USER, $row->fa_user_text ) );
954 $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->fa_user_text ) );
955 }
956 $batch->execute();
957 $files->seek( 0 );
958 }
959
960 if ( $this->mAllowed ) {
961 $titleObj = SpecialPage::getTitleFor( "Undelete" );
962 $action = $titleObj->getLocalURL( "action=submit" );
963 # Start the form here
964 $top = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'undelete' ) );
965 $wgOut->addHtml( $top );
966 }
967
968 # Show relevant lines from the deletion log:
969 $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) . "\n" );
970 LogEventsList::showLogExtract( $wgOut, 'delete', $this->mTargetObj->getPrefixedText() );
971
972 if( $this->mAllowed && ( $haveRevisions || $haveFiles ) ) {
973 # Format the user-visible controls (comment field, submission button)
974 # in a nice little table
975 if( $wgUser->isAllowed( 'suppressrevision' ) ) {
976 $unsuppressBox =
977 "<tr>
978 <td>&nbsp;</td>
979 <td class='mw-input'>" .
980 Xml::checkLabel( wfMsg('revdelete-unsuppress'), 'wpUnsuppress',
981 'mw-undelete-unsuppress', $this->mUnsuppress ).
982 "</td>
983 </tr>";
984 } else {
985 $unsuppressBox = "";
986 }
987 $table =
988 Xml::openElement( 'fieldset' ) .
989 Xml::element( 'legend', null, wfMsg( 'undelete-fieldset-title' ) ).
990 Xml::openElement( 'table', array( 'id' => 'mw-undelete-table' ) ) .
991 "<tr>
992 <td colspan='2'>" .
993 wfMsgWikiHtml( 'undeleteextrahelp' ) .
994 "</td>
995 </tr>
996 <tr>
997 <td class='mw-label'>" .
998 Xml::label( wfMsg( 'undeletecomment' ), 'wpComment' ) .
999 "</td>
1000 <td class='mw-input'>" .
1001 Xml::input( 'wpComment', 50, $this->mComment, array( 'id' => 'wpComment' ) ) .
1002 "</td>
1003 </tr>
1004 <tr>
1005 <td>&nbsp;</td>
1006 <td class='mw-submit'>" .
1007 Xml::submitButton( wfMsg( 'undeletebtn' ), array( 'name' => 'restore', 'id' => 'mw-undelete-submit' ) ) .
1008 Xml::element( 'input', array( 'type' => 'reset', 'value' => wfMsg( 'undeletereset' ), 'id' => 'mw-undelete-reset' ) ) .
1009 "</td>
1010 </tr>" .
1011 $unsuppressBox .
1012 Xml::closeElement( 'table' ) .
1013 Xml::closeElement( 'fieldset' );
1014
1015 $wgOut->addHtml( $table );
1016 }
1017
1018 $wgOut->addHTML( Xml::element( 'h2', null, wfMsg( 'history' ) ) . "\n" );
1019
1020 if( $haveRevisions ) {
1021 # The page's stored (deleted) history:
1022 $wgOut->addHTML("<ul>");
1023 $target = urlencode( $this->mTarget );
1024 $remaining = $revisions->numRows();
1025 $earliestLiveTime = $this->getEarliestTime( $this->mTargetObj );
1026
1027 while( $row = $revisions->fetchObject() ) {
1028 $remaining--;
1029 $wgOut->addHTML( $this->formatRevisionRow( $row, $earliestLiveTime, $remaining, $sk ) );
1030 }
1031 $revisions->free();
1032 $wgOut->addHTML("</ul>");
1033 } else {
1034 $wgOut->addWikiMsg( "nohistory" );
1035 }
1036
1037 if( $haveFiles ) {
1038 $wgOut->addHtml( Xml::element( 'h2', null, wfMsg( 'filehist' ) ) . "\n" );
1039 $wgOut->addHtml( "<ul>" );
1040 while( $row = $files->fetchObject() ) {
1041 $wgOut->addHTML( $this->formatFileRow( $row, $sk ) );
1042 }
1043 $files->free();
1044 $wgOut->addHTML( "</ul>" );
1045 }
1046
1047 if ( $this->mAllowed ) {
1048 # Slip in the hidden controls here
1049 $misc = Xml::hidden( 'target', $this->mTarget );
1050 $misc .= Xml::hidden( 'wpEditToken', $wgUser->editToken() );
1051 $misc .= Xml::closeElement( 'form' );
1052 $wgOut->addHtml( $misc );
1053 }
1054
1055 return true;
1056 }
1057
1058 private function formatRevisionRow( $row, $earliestLiveTime, $remaining, $sk ) {
1059 global $wgUser, $wgLang;
1060
1061 $rev = new Revision( array(
1062 'page' => $this->mTargetObj->getArticleId(),
1063 'comment' => $row->ar_comment,
1064 'user' => $row->ar_user,
1065 'user_text' => $row->ar_user_text,
1066 'timestamp' => $row->ar_timestamp,
1067 'minor_edit' => $row->ar_minor_edit,
1068 'deleted' => $row->ar_deleted,
1069 'len' => $row->ar_len ) );
1070
1071 $stxt = '';
1072 $ts = wfTimestamp( TS_MW, $row->ar_timestamp );
1073 if( $this->mAllowed ) {
1074 $checkBox = Xml::check( "ts$ts" );
1075 $titleObj = SpecialPage::getTitleFor( "Undelete" );
1076 $pageLink = $this->getPageLink( $rev, $titleObj, $ts, $sk );
1077 # Last link
1078 if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
1079 $last = wfMsgHtml('diff');
1080 } else if( $remaining > 0 || ($earliestLiveTime && $ts > $earliestLiveTime) ) {
1081 $last = $sk->makeKnownLinkObj( $titleObj, wfMsgHtml('diff'),
1082 "target=" . $this->mTargetObj->getPrefixedUrl() . "&timestamp=$ts&diff=prev" );
1083 } else {
1084 $last = wfMsgHtml('diff');
1085 }
1086 } else {
1087 $checkBox = '';
1088 $pageLink = $wgLang->timeanddate( $ts, true );
1089 $last = wfMsgHtml('diff');
1090 }
1091 $userLink = $sk->revUserTools( $rev );
1092
1093 if(!is_null($size = $row->ar_len)) {
1094 $stxt = $sk->formatRevisionSize( $size );
1095 }
1096 $comment = $sk->revComment( $rev );
1097 $revdlink = '';
1098 if( $wgUser->isAllowed( 'deleterevision' ) ) {
1099 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
1100 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
1101 // If revision was hidden from sysops
1102 $del = wfMsgHtml('rev-delundel');
1103 } else {
1104 $ts = wfTimestamp( TS_MW, $row->ar_timestamp );
1105 $del = $sk->makeKnownLinkObj( $revdel,
1106 wfMsgHtml('rev-delundel'),
1107 'target=' . $this->mTargetObj->getPrefixedUrl() . "&artimestamp=$ts" );
1108 // Bolden oversighted content
1109 if( $rev->isDeleted( Revision::DELETED_RESTRICTED ) )
1110 $del = "<strong>$del</strong>";
1111 }
1112 $revdlink = "<tt>(<small>$del</small>)</tt>";
1113 }
1114
1115 return "<li>$checkBox $revdlink ($last) $pageLink . . $userLink $stxt $comment</li>";
1116 }
1117
1118 private function formatFileRow( $row, $sk ) {
1119 global $wgUser, $wgLang;
1120
1121 $file = ArchivedFile::newFromRow( $row );
1122
1123 $ts = wfTimestamp( TS_MW, $row->fa_timestamp );
1124 if( $this->mAllowed && $row->fa_storage_key ) {
1125 $checkBox = Xml::check( "fileid" . $row->fa_id );
1126 $key = urlencode( $row->fa_storage_key );
1127 $target = urlencode( $this->mTarget );
1128 $titleObj = SpecialPage::getTitleFor( "Undelete" );
1129 $pageLink = $this->getFileLink( $file, $titleObj, $ts, $key, $sk );
1130 } else {
1131 $checkBox = '';
1132 $pageLink = $wgLang->timeanddate( $ts, true );
1133 }
1134 $userLink = $this->getFileUser( $file, $sk );
1135 $data =
1136 wfMsg( 'widthheight',
1137 $wgLang->formatNum( $row->fa_width ),
1138 $wgLang->formatNum( $row->fa_height ) ) .
1139 ' (' .
1140 wfMsg( 'nbytes', $wgLang->formatNum( $row->fa_size ) ) .
1141 ')';
1142 $data = htmlspecialchars( $data );
1143 $comment = $this->getFileComment( $file, $sk );
1144 $revdlink = '';
1145 if( $wgUser->isAllowed( 'deleterevision' ) ) {
1146 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
1147 if( !$file->userCan(File::DELETED_RESTRICTED ) ) {
1148 // If revision was hidden from sysops
1149 $del = wfMsgHtml('rev-delundel');
1150 } else {
1151 $del = $sk->makeKnownLinkObj( $revdel,
1152 wfMsgHtml('rev-delundel'),
1153 'target=' . $this->mTargetObj->getPrefixedUrl() .
1154 '&fileid=' . $row->fa_id );
1155 // Bolden oversighted content
1156 if( $file->isDeleted( File::DELETED_RESTRICTED ) )
1157 $del = "<strong>$del</strong>";
1158 }
1159 $revdlink = "<tt>(<small>$del</small>)</tt>";
1160 }
1161 return "<li>$checkBox $revdlink $pageLink . . $userLink $data $comment</li>\n";
1162 }
1163
1164 private function getEarliestTime( $title ) {
1165 $dbr = wfGetDB( DB_SLAVE );
1166 if( $title->exists() ) {
1167 $min = $dbr->selectField( 'revision',
1168 'MIN(rev_timestamp)',
1169 array( 'rev_page' => $title->getArticleId() ),
1170 __METHOD__ );
1171 return wfTimestampOrNull( TS_MW, $min );
1172 }
1173 return null;
1174 }
1175
1176 /**
1177 * Fetch revision text link if it's available to all users
1178 * @return string
1179 */
1180 function getPageLink( $rev, $titleObj, $ts, $sk ) {
1181 global $wgLang;
1182
1183 if( !$rev->userCan(Revision::DELETED_TEXT) ) {
1184 return '<span class="history-deleted">' . $wgLang->timeanddate( $ts, true ) . '</span>';
1185 } else {
1186 $link = $sk->makeKnownLinkObj( $titleObj, $wgLang->timeanddate( $ts, true ),
1187 "target=".$this->mTargetObj->getPrefixedUrl()."&timestamp=$ts" );
1188 if( $rev->isDeleted(Revision::DELETED_TEXT) )
1189 $link = '<span class="history-deleted">' . $link . '</span>';
1190 return $link;
1191 }
1192 }
1193
1194 /**
1195 * Fetch image view link if it's available to all users
1196 * @return string
1197 */
1198 function getFileLink( $file, $titleObj, $ts, $key, $sk ) {
1199 global $wgLang;
1200
1201 if( !$file->userCan(File::DELETED_FILE) ) {
1202 return '<span class="history-deleted">' . $wgLang->timeanddate( $ts, true ) . '</span>';
1203 } else {
1204 $link = $sk->makeKnownLinkObj( $titleObj, $wgLang->timeanddate( $ts, true ),
1205 "target=".$this->mTargetObj->getPrefixedUrl()."&file=$key" );
1206 if( $file->isDeleted(File::DELETED_FILE) )
1207 $link = '<span class="history-deleted">' . $link . '</span>';
1208 return $link;
1209 }
1210 }
1211
1212 /**
1213 * Fetch file's user id if it's available to this user
1214 * @return string
1215 */
1216 function getFileUser( $file, $sk ) {
1217 if( !$file->userCan(File::DELETED_USER) ) {
1218 return '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
1219 } else {
1220 $link = $sk->userLink( $file->getRawUser(), $file->getRawUserText() ) .
1221 $sk->userToolLinks( $file->getRawUser(), $file->getRawUserText() );
1222 if( $file->isDeleted(File::DELETED_USER) )
1223 $link = '<span class="history-deleted">' . $link . '</span>';
1224 return $link;
1225 }
1226 }
1227
1228 /**
1229 * Fetch file upload comment if it's available to this user
1230 * @return string
1231 */
1232 function getFileComment( $file, $sk ) {
1233 if( !$file->userCan(File::DELETED_COMMENT) ) {
1234 return '<span class="history-deleted"><span class="comment">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span></span>';
1235 } else {
1236 $link = $sk->commentBlock( $file->getRawDescription() );
1237 if( $file->isDeleted(File::DELETED_COMMENT) )
1238 $link = '<span class="history-deleted">' . $link . '</span>';
1239 return $link;
1240 }
1241 }
1242
1243 function undelete() {
1244 global $wgOut, $wgUser;
1245 if ( wfReadOnly() ) {
1246 $wgOut->readOnlyPage();
1247 return;
1248 }
1249 if( !is_null( $this->mTargetObj ) ) {
1250 $archive = new PageArchive( $this->mTargetObj );
1251 $ok = $archive->undelete(
1252 $this->mTargetTimestamp,
1253 $this->mComment,
1254 $this->mFileVersions,
1255 $this->mUnsuppress );
1256
1257 if( is_array($ok) ) {
1258 if ( $ok[1] ) // Undeleted file count
1259 wfRunHooks( 'FileUndeleteComplete', array(
1260 $this->mTargetObj, $this->mFileVersions,
1261 $wgUser, $this->mComment) );
1262
1263 $skin = $wgUser->getSkin();
1264 $link = $skin->makeKnownLinkObj( $this->mTargetObj );
1265 $wgOut->addHtml( wfMsgWikiHtml( 'undeletedpage', $link ) );
1266 } else {
1267 $wgOut->showFatalError( wfMsg( "cannotundelete" ) );
1268 $wgOut->addHtml( '<p>' . wfMsgHtml( "undeleterevdel" ) . '</p>' );
1269 }
1270
1271 // Show file deletion warnings and errors
1272 $status = $archive->getFileStatus();
1273 if( $status && !$status->isGood() ) {
1274 $wgOut->addWikiText( $status->getWikiText( 'undelete-error-short', 'undelete-error-long' ) );
1275 }
1276 } else {
1277 $wgOut->showFatalError( wfMsg( "cannotundelete" ) );
1278 }
1279 return false;
1280 }
1281 }