X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FRevisionList.php;h=811870c8c0c22e6afb09a92b260ef9b1eb138846;hb=fb4470ae12e59207f1e4337db305ec5a942a89e9;hp=d10b5412cb19d48f09ffb815ef16b178fc0de0ef;hpb=7f0ab4a8250305f959b86e59b7df31c37010535f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/RevisionList.php b/includes/RevisionList.php index d10b5412cb..811870c8c0 100644 --- a/includes/RevisionList.php +++ b/includes/RevisionList.php @@ -23,13 +23,14 @@ /** * List for revision table items for a single page */ -abstract class RevisionListBase extends ContextSource { +abstract class RevisionListBase extends ContextSource implements Iterator { /** @var Title */ public $title; /** @var array */ protected $ids; + /** @var ResultWrapper|bool */ protected $res; /** @var bool|object */ @@ -88,6 +89,10 @@ abstract class RevisionListBase extends ContextSource { return $this->current; } + public function rewind() { + $this->reset(); + } + /** * Get the current list item, or false if we are at the end * @return Revision @@ -106,6 +111,14 @@ abstract class RevisionListBase extends ContextSource { return $this->current; } + public function key() { + return $this->res ? $this->res->key(): 0; + } + + public function valid() { + return $this->res ? $this->res->valid() : false; + } + /** * Get the number of items in the list. * @return int @@ -120,7 +133,7 @@ abstract class RevisionListBase extends ContextSource { /** * Do the DB query to iterate through the objects. - * @param DatabaseBase $db DatabaseBase object to use for the query + * @param IDatabase $db DB object to use for the query */ abstract public function doQuery( $db ); @@ -263,23 +276,23 @@ class RevisionList extends RevisionListBase { } /** - * @param DatabaseBase $db + * @param IDatabase $db * @return mixed */ public function doQuery( $db ) { - $conds = array( 'rev_page' => $this->title->getArticleID() ); + $conds = [ 'rev_page' => $this->title->getArticleID() ]; if ( $this->ids !== null ) { $conds['rev_id'] = array_map( 'intval', $this->ids ); } return $db->select( - array( 'revision', 'page', 'user' ), + [ 'revision', 'page', 'user' ], array_merge( Revision::selectFields(), Revision::selectUserFields() ), $conds, __METHOD__, - array( 'ORDER BY' => 'rev_id DESC' ), - array( + [ 'ORDER BY' => 'rev_id DESC' ], + [ 'page' => Revision::pageJoinCond(), - 'user' => Revision::userJoinCond() ) + 'user' => Revision::userJoinCond() ] ); } @@ -317,7 +330,7 @@ class RevisionItem extends RevisionItemBase { } public function getAuthorNameField() { - return 'user_name'; // see Revision::selectUserFields() + return 'rev_user_text'; } public function canView() { @@ -334,51 +347,59 @@ class RevisionItem extends RevisionItemBase { /** * Get the HTML link to the revision text. - * Overridden by RevDelArchiveItem. + * @todo Essentially a copy of RevDelRevisionItem::getRevisionLink. That class + * should inherit from this one, and implement an appropriate interface instead + * of extending RevDelItem * @return string */ protected function getRevisionLink() { - $date = $this->list->getLanguage()->timeanddate( $this->revision->getTimestamp(), true ); + $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate( + $this->revision->getTimestamp(), $this->list->getUser() ) ); + if ( $this->isDeleted() && !$this->canViewContent() ) { return $date; } - return Linker::link( + return Linker::linkKnown( $this->list->title, $date, - array(), - array( + [], + [ 'oldid' => $this->revision->getId(), 'unhide' => 1 - ) + ] ); } /** * Get the HTML link to the diff. - * Overridden by RevDelArchiveItem + * @todo Essentially a copy of RevDelRevisionItem::getDiffLink. That class + * should inherit from this one, and implement an appropriate interface instead + * of extending RevDelItem * @return string */ protected function getDiffLink() { if ( $this->isDeleted() && !$this->canViewContent() ) { return $this->context->msg( 'diff' )->escaped(); } else { - return Linker::link( + return Linker::linkKnown( $this->list->title, - $this->context->msg( 'diff' )->escaped(), - array(), - array( + $this->list->msg( 'diff' )->escaped(), + [], + [ 'diff' => $this->revision->getId(), 'oldid' => 'prev', 'unhide' => 1 - ), - array( - 'known', - 'noclasses' - ) + ] ); } } + /** + * @todo Essentially a copy of RevDelRevisionItem::getHTML. That class + * should inherit from this one, and implement an appropriate interface instead + * of extending RevDelItem + * @return string + */ public function getHTML() { $difflink = $this->context->msg( 'parentheses' ) ->rawParams( $this->getDiffLink() )->escaped();