Merge "includes/resourceloader/: Use Config instead of globals"
[lhc/web/wiklou.git] / includes / revisiondelete / RevDelArchiveItem.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup RevisionDelete
20 */
21
22 /**
23 * Item class for a archive table row
24 */
25 class RevDelArchiveItem extends RevDelRevisionItem {
26 public function __construct( $list, $row ) {
27 RevDelItem::__construct( $list, $row );
28 $this->revision = Revision::newFromArchiveRow( $row, array( 'page' => $this->list->title->getArticleID() ) );
29 }
30
31 public function getIdField() {
32 return 'ar_timestamp';
33 }
34
35 public function getTimestampField() {
36 return 'ar_timestamp';
37 }
38
39 public function getAuthorIdField() {
40 return 'ar_user';
41 }
42
43 public function getAuthorNameField() {
44 return 'ar_user_text';
45 }
46
47 public function getId() {
48 # Convert DB timestamp to MW timestamp
49 return $this->revision->getTimestamp();
50 }
51
52 public function setBits( $bits ) {
53 $dbw = wfGetDB( DB_MASTER );
54 $dbw->update( 'archive', array( 'ar_deleted' => $bits ), array( 'ar_namespace' => $this->list->title->getNamespace(), 'ar_title' => $this->list->title->getDBkey(), // use timestamp for index
55 'ar_timestamp' => $this->row->ar_timestamp, 'ar_rev_id' => $this->row->ar_rev_id, 'ar_deleted' => $this->getBits() ), __METHOD__ );
56
57 return (bool) $dbw->affectedRows();
58 }
59
60 protected function getRevisionLink() {
61 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate( $this->revision->getTimestamp(), $this->list->getUser() ) );
62
63 if ( $this->isDeleted() && !$this->canViewContent() ) {
64 return $date;
65 }
66
67 return Linker::link( SpecialPage::getTitleFor( 'Undelete' ), $date, array(), array( 'target' => $this->list->title->getPrefixedText(), 'timestamp' => $this->revision->getTimestamp() ) );
68 }
69
70 protected function getDiffLink() {
71 if ( $this->isDeleted() && !$this->canViewContent() ) {
72 return $this->list->msg( 'diff' )->escaped();
73 }
74
75 return Linker::link( SpecialPage::getTitleFor( 'Undelete' ), $this->list->msg( 'diff' )->escaped(), array(), array( 'target' => $this->list->title->getPrefixedText(), 'diff' => 'prev', 'timestamp' => $this->revision->getTimestamp() ) );
76 }
77 }