[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/revisiondelete/ -> RevDelArchivedFileItem.php (source)

   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 filearchive table row
  24   */
  25  class RevDelArchivedFileItem extends RevDelFileItem {
  26  	public function __construct( $list, $row ) {
  27          RevDelItem::__construct( $list, $row );
  28          $this->file = ArchivedFile::newFromRow( $row );
  29      }
  30  
  31  	public function getIdField() {
  32          return 'fa_id';
  33      }
  34  
  35  	public function getTimestampField() {
  36          return 'fa_timestamp';
  37      }
  38  
  39  	public function getAuthorIdField() {
  40          return 'fa_user';
  41      }
  42  
  43  	public function getAuthorNameField() {
  44          return 'fa_user_text';
  45      }
  46  
  47  	public function getId() {
  48          return $this->row->fa_id;
  49      }
  50  
  51  	public function setBits( $bits ) {
  52          $dbw = wfGetDB( DB_MASTER );
  53          $dbw->update( 'filearchive',
  54              array( 'fa_deleted' => $bits ),
  55              array(
  56                  'fa_id' => $this->row->fa_id,
  57                  'fa_deleted' => $this->getBits(),
  58              ),
  59              __METHOD__
  60          );
  61  
  62          return (bool)$dbw->affectedRows();
  63      }
  64  
  65  	protected function getLink() {
  66          $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
  67              $this->file->getTimestamp(), $this->list->getUser() ) );
  68  
  69          # Hidden files...
  70          if ( !$this->canViewContent() ) {
  71              $link = $date;
  72          } else {
  73              $undelete = SpecialPage::getTitleFor( 'Undelete' );
  74              $key = $this->file->getKey();
  75              $link = Linker::link( $undelete, $date, array(),
  76                  array(
  77                      'target' => $this->list->title->getPrefixedText(),
  78                      'file' => $key,
  79                      'token' => $this->list->getUser()->getEditToken( $key )
  80                  )
  81              );
  82          }
  83          if ( $this->isDeleted() ) {
  84              $link = '<span class="history-deleted">' . $link . '</span>';
  85          }
  86  
  87          return $link;
  88      }
  89  
  90  	public function getApiData( ApiResult $result ) {
  91          $file = $this->file;
  92          $user = $this->list->getUser();
  93          $ret = array(
  94              'title' => $this->list->title->getPrefixedText(),
  95              'timestamp' => wfTimestamp( TS_ISO_8601, $file->getTimestamp() ),
  96              'width' => $file->getWidth(),
  97              'height' => $file->getHeight(),
  98              'size' => $file->getSize(),
  99          );
 100          $ret += $file->isDeleted( Revision::DELETED_USER ) ? array( 'userhidden' => '' ) : array();
 101          $ret += $file->isDeleted( Revision::DELETED_COMMENT ) ? array( 'commenthidden' => '' ) : array();
 102          $ret += $this->isDeleted() ? array( 'contenthidden' => '' ) : array();
 103          if ( $this->canViewContent() ) {
 104              $ret += array(
 105                  'url' => SpecialPage::getTitleFor( 'Revisiondelete' )->getLinkURL(
 106                      array(
 107                          'target' => $this->list->title->getPrefixedText(),
 108                          'file' => $file->getKey(),
 109                          'token' => $user->getEditToken( $file->getKey() )
 110                      ),
 111                      false, PROTO_RELATIVE
 112                  ),
 113              );
 114          }
 115          if ( $file->userCan( Revision::DELETED_USER, $user ) ) {
 116              $ret += array(
 117                  'userid' => $file->getUser( 'id' ),
 118                  'user' => $file->getUser( 'text' ),
 119              );
 120          }
 121          if ( $file->userCan( Revision::DELETED_COMMENT, $user ) ) {
 122              $ret += array(
 123                  'comment' => $file->getRawDescription(),
 124              );
 125          }
 126  
 127          return $ret;
 128      }
 129  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1