MediaWiki  REL1_24
RevDelArchivedFileItem.php
Go to the documentation of this file.
00001 <?php
00025 class RevDelArchivedFileItem extends RevDelFileItem {
00026     public function __construct( $list, $row ) {
00027         RevDelItem::__construct( $list, $row );
00028         $this->file = ArchivedFile::newFromRow( $row );
00029     }
00030 
00031     public function getIdField() {
00032         return 'fa_id';
00033     }
00034 
00035     public function getTimestampField() {
00036         return 'fa_timestamp';
00037     }
00038 
00039     public function getAuthorIdField() {
00040         return 'fa_user';
00041     }
00042 
00043     public function getAuthorNameField() {
00044         return 'fa_user_text';
00045     }
00046 
00047     public function getId() {
00048         return $this->row->fa_id;
00049     }
00050 
00051     public function setBits( $bits ) {
00052         $dbw = wfGetDB( DB_MASTER );
00053         $dbw->update( 'filearchive',
00054             array( 'fa_deleted' => $bits ),
00055             array(
00056                 'fa_id' => $this->row->fa_id,
00057                 'fa_deleted' => $this->getBits(),
00058             ),
00059             __METHOD__
00060         );
00061 
00062         return (bool)$dbw->affectedRows();
00063     }
00064 
00065     protected function getLink() {
00066         $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
00067             $this->file->getTimestamp(), $this->list->getUser() ) );
00068 
00069         # Hidden files...
00070         if ( !$this->canViewContent() ) {
00071             $link = $date;
00072         } else {
00073             $undelete = SpecialPage::getTitleFor( 'Undelete' );
00074             $key = $this->file->getKey();
00075             $link = Linker::link( $undelete, $date, array(),
00076                 array(
00077                     'target' => $this->list->title->getPrefixedText(),
00078                     'file' => $key,
00079                     'token' => $this->list->getUser()->getEditToken( $key )
00080                 )
00081             );
00082         }
00083         if ( $this->isDeleted() ) {
00084             $link = '<span class="history-deleted">' . $link . '</span>';
00085         }
00086 
00087         return $link;
00088     }
00089 
00090     public function getApiData( ApiResult $result ) {
00091         $file = $this->file;
00092         $user = $this->list->getUser();
00093         $ret = array(
00094             'title' => $this->list->title->getPrefixedText(),
00095             'timestamp' => wfTimestamp( TS_ISO_8601, $file->getTimestamp() ),
00096             'width' => $file->getWidth(),
00097             'height' => $file->getHeight(),
00098             'size' => $file->getSize(),
00099         );
00100         $ret += $file->isDeleted( Revision::DELETED_USER ) ? array( 'userhidden' => '' ) : array();
00101         $ret += $file->isDeleted( Revision::DELETED_COMMENT ) ? array( 'commenthidden' => '' ) : array();
00102         $ret += $this->isDeleted() ? array( 'contenthidden' => '' ) : array();
00103         if ( $this->canViewContent() ) {
00104             $ret += array(
00105                 'url' => SpecialPage::getTitleFor( 'Revisiondelete' )->getLinkURL(
00106                     array(
00107                         'target' => $this->list->title->getPrefixedText(),
00108                         'file' => $file->getKey(),
00109                         'token' => $user->getEditToken( $file->getKey() )
00110                     ),
00111                     false, PROTO_RELATIVE
00112                 ),
00113             );
00114         }
00115         if ( $file->userCan( Revision::DELETED_USER, $user ) ) {
00116             $ret += array(
00117                 'userid' => $file->getUser( 'id' ),
00118                 'user' => $file->getUser( 'text' ),
00119             );
00120         }
00121         if ( $file->userCan( Revision::DELETED_COMMENT, $user ) ) {
00122             $ret += array(
00123                 'comment' => $file->getRawDescription(),
00124             );
00125         }
00126 
00127         return $ret;
00128     }
00129 }